forked from 43215-Anuj/data-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.java
More file actions
43 lines (39 loc) · 830 Bytes
/
Copy pathDemo.java
File metadata and controls
43 lines (39 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.*;
class Demo
{
public static void main(String[] args)
{
Scanner sc= new Scanner (System.in);
int i,j;
char ch;
System.out.println("Enter 1st number: ");
i=sc.nextInt();
System.out.println("Enter 2nd number: ");
j=sc.nextInt();
System.out.println("1 . Add ");
System.out.println("2 . SUb ");
System.out.println("what is your choice :");
ch=sc.next().charAt(0);
switch(ch)
{
case '1' : int sum= add(i,j);
System.out.println("Sum = " + sum);
break;
case '2' : sub(i,j); break;
default: System.out.println("wrong ");
}
}
public static int add(int i, int j)
{
int sum;
sum= i+j;
//System.out.println("sum =" sum);
return sum;
}
public static void sub(int i, int j)
{
int diff;
diff= i-j;
System.out.println("Difference =" + diff);
}
}