-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmini calculator
More file actions
58 lines (55 loc) · 1.55 KB
/
mini calculator
File metadata and controls
58 lines (55 loc) · 1.55 KB
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
import java.util.*;
public class mini_calculator
{
public static int addition(){
Scanner sc=new Scanner(System.in);
System.out.println("enter the numbers");
int a=sc.nextInt();
int b=sc.nextInt();
return(a+b);
}
public static int substraction(){
Scanner sc=new Scanner(System.in);
System.out.println("enter the numbers");
int a=sc.nextInt();
int b=sc.nextInt();
return(a+b);
}
public static int multiplication(){
Scanner sc=new Scanner(System.in);
System.out.println("enter the numbers");
int a=sc.nextInt();
int b=sc.nextInt();
return(a*b);
}
public static int division(){
Scanner sc=new Scanner(System.in);
System.out.println("enter the numbers");
int a=sc.nextInt();
int b=sc.nextInt();
return(a/b);
}
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
System.out.println("enter your response:\n1.addition\n2.substraction\n3.multiplication\n4.division");
int x=sc.nextInt();
if(x==1){
int a=addition();
System.out.println(a);
}
else if(x==2){
int s=substraction();
System.out.println(s);
}
else if(x==3){
int m=multiplication();
System.out.println(m);
}
else if(x==4){
int d=division();
System.out.println(d);
}
else
System.out.println("invalid option");
}
}