-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCal.java
More file actions
41 lines (32 loc) · 779 Bytes
/
Cal.java
File metadata and controls
41 lines (32 loc) · 779 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
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class Cal {
public static void main(String[] args) {
System.out.println("Enter First Number:");
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
System.out.println("First Number:\t"+a);
System.out.println("Enter Second Number:");
int b=sc.nextInt();
System.out.println("Second Number:\t"+b);
System.out.println("Select Operation: 1.add,2.sub,3.mul,4.div");
int c,add,sub,mul,div;
int s=sc.nextInt();
if(s==1) {
c=a+b;
System.out.println("Addition: "+c);
}
if(s==2) {
c=a-b;
System.out.println("Substraction: "+c);
}
if(s==3) {
c=a*b;
System.out.println("Multiplication: "+c);
}
if(s==4) {
c=a/b;
System.out.println("Division: "+c);
}
sc.close();
}
}