-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.java
More file actions
25 lines (25 loc) · 911 Bytes
/
Copy pathcalc.java
File metadata and controls
25 lines (25 loc) · 911 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
import java.util.*;
public class calc{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Enter first no.");
int a=sc.nextInt();
System.out.println("Enter second no.");
int b=sc.nextInt();
System.out.println("Enter 1 for + ,2 for - ,3 for *, 4 for /,5 for %");
int c=sc.nextInt();
if(c==1)
System.out.println("The sum of a and b is ="+(a+b));
else if(c==2)
System.out.println("The difference of a and b is ="+(a-b));
else if(c==3)
System.out.println("The * of a and b is ="+(a*b));
else if(c==4)
System.out.println("The / of a and b is ="+(a/b));
else if(c==5)
System.out.println("The % of a and b is ="+(a%b));
else
System.out.println("invalid choice");
sc.close();
}
}