-
Notifications
You must be signed in to change notification settings - Fork 29
/
Calculator.java
56 lines (49 loc) · 1.5 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
package Java-Projects-For-Hacktoberfest-2022;
import java.util.*;
class Calculator
{
public class Calculator
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);
int ch,a,b;
float c,d;
System.out.println("****** Enter your choice ******");
System.out.println("1.Press 1 for Addition");
System.out.println("2.Press 2 for Subtract");
System.out.println("3.Press 3 for Multiply");
System.out.println("4.Press 4 for Divison");
ch=sc.nextInt();
switch(ch)
{
case 1:
System.out.println("Enter the two numbers:");
a=sc.nextInt();
b=sc.nextInt();
System.out.println("The addition is:"+(a+b));
break;
case 2:
System.out.println("Enter the two numbers:");
a=sc.nextInt();
b=sc.nextInt();
System.out.println("The Subtract is:"+(a-b));
break;
case 3:
System.out.println("Enter the two numbers:");
a=sc.nextInt();
b=sc.nextInt();
System.out.println("The Multiplication is:"+(a*b));
break;
case 4:
System.out.println("Enter the two numbers:");
c=sc.nextFloat();
d=sc.nextFloat();
System.out.println("The Divison is:"+(c/d));
break;
default:
System.out.println("Invalid Choice");
break;
}
}
}