-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
28 lines (28 loc) · 703 Bytes
/
Test.java
File metadata and controls
28 lines (28 loc) · 703 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
import java.util.scanner;
public class caladd{
pulbic static void main(String args[])
{
float a,b,res;
char choice,ch;
Scanner scan=new scanner(System.in);
do
{
System.out.println("Enter two numbers\n");
System.out.println("2.Exit\n");
System.out.print("3.Enter your choice:");
choice=scan.next().charAt(0);
switch(choice)
{
case '1': System.out.print("Enter your number:");
a=scan.nextFloat();
b=scan.nextFloat();
res=a+b;
System.out.print("Result=" +res);
break;
case '2': System.exit(0);
break;
default : System.out.print("Invalid choice!");
break;
}
System.out.print("\n----------------------------------\n");
}while(choice!=2);