-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiv.java
More file actions
46 lines (43 loc) · 1.17 KB
/
div.java
File metadata and controls
46 lines (43 loc) · 1.17 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
import java.util.*;
import java.io.*;
import java.lang.*;
class div_Main{
public static void main(String[] args) throws IOException {
float a,b,res;
char choice,ch;
Scanner scan = new Scanner(System.in);
do{
System.out.print("1.ADD TWO NUmbers\n");
System.out.print("3.Multiply two numbers\n");
System.out.print("4.Subtract two numbers\n");
System.out.print("2.Exit\n");
System.out.print("Enter the choice:");
choice=scan.next().charAt(0);
switch(choice){
case '1': System.out.print("Enter the two numbers:");
a=scan.nextFloat();
b=scan.nextFloat();
res = a+b;
System.out.print("Result= "+res);
break;
case '2': System.exit(0);
break;
case '3': System.out.print("Enter the two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
res = a*b;
System.out.print("Result= "+res);
break;
case '4': System.out.print("Enter the two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
res = a-b;
System.out.print("Result= "+res);
break;
default: System.out.print("Invalid CHOICE!!!!");
break;
}
System.out.print("\n------------------");
}while(choice!='2');
}
}