-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.java
71 lines (46 loc) · 1.17 KB
/
Calculator.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.util.*;
class Calculator{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
float no1,no2,add,sub,mul,div,total,avg;
int ch;
do
{
System.out.println("Enter Number 1 and Number 2 : ");
no1=in.nextFloat();
no2=in.nextFloat();
System.out.println("Enter your choise :\n1.Addition\n2.Substraction \n3.Multiplication \n4.Division \n5.Total \n6.Average");
ch=in.nextInt();
switch(ch)
{
case 1:
add=no1+no2;
System.out.println("Addition = "+add);
break;
case 2:
sub=no1+-no2;
System.out.println("Substraction = "+sub);
break;
case 3:
mul=no1*no2;
System.out.println("Multiplication = "+mul);
break;
case 4:
div=no1/no2;
System.out.println("Division = "+div);
break;
case 5:
total=no1+no2;
System.out.println("Total = "+total);
break;
case 6:
avg=(no1+no2)/2;
System.out.println("Average = "+avg);
break;
default:
System.out.println("Cannot find case");
}
}while(ch!=0);
}
}