-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaladd.java
More file actions
49 lines (40 loc) · 2.13 KB
/
caladd.java
File metadata and controls
49 lines (40 loc) · 2.13 KB
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
44
45
46
47
48
import java.util.Scanner;
public class caladd{
public static void main(String args[]){
float a,b,res;
char choice,ch;
Scanner scan = new Scanner(System.in);
do {
System.out.print("\n1.Add two numbers\n");
System.out.print("2.Multiplication of two numbers\n");
System.out.print("\n3.Subtract two numbers\n");
System.out.print("4.Exit\n\n");
System.out.print("Enter your choice : ");
choice = scan.next().charAt(0);
switch(choice){
case '1' : System.out.print("Enter two numbers :");
a = scan.nextFloat();
b = scan.nextFloat();
res = a+b;
System.out.print("Result = " + res);
break;
case '2' : System.out.print("Enter two numbers :");
a = scan.nextFloat();
b = scan.nextFloat();
res = a-b;
System.out.print("Result = " + res);
break;
case '3' : System.out.print("Enter two numbers :");
a = scan.nextFloat();
b = scan.nextFloat();
res = a*b;
System.out.print("Result = " + res);
break;
case '4' : System.exit(0);
break;
default : System.out.print("Invalid Choice \n"); break;
}
System.out.print("\n======================");
} while(choice != '4');
}
}