-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator
More file actions
27 lines (25 loc) · 810 Bytes
/
calculator
File metadata and controls
27 lines (25 loc) · 810 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
package com.sample;
import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int a=sc.nextInt();
int b= sc.nextInt();
System.out.println("enter 1 for add");
System.out.println("enter 2for sub");
System.out.println("enter 3for mul");
System.out.println("enter 4for div");
int n= sc.nextInt();
switch(n)
{
case 1:System.out.println("two numbers "+a+ "+"+b+"= "+(a+b));
break;
case 2:System.out.println("two numbers "+a+ "-"+b+"="+(a-b));
break;
case 3:System.out.println("two numbers "+a+ "*"+b+"="+a*b);
break;
case 4:System.out.println("two numbers "+a+ "/"+b+"="+a/b);
break;
}
}
}