-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator_Interface.java
More file actions
65 lines (62 loc) · 1.67 KB
/
Calculator_Interface.java
File metadata and controls
65 lines (62 loc) · 1.67 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
59
60
61
62
63
64
65
import java.util.Scanner;
interface Calculator_cal
{
void add();
void sub();
void mul();
void div();
}
class calculator implements Calculator_cal
{
Scanner scanner = new Scanner(System.in);
public void add()
{
int res,a,b;
System.out.println("Enter a Value to Add: ");
a=scanner.nextInt();
System.out.println("Enter a Value to Add: ");
b=scanner.nextInt();
res=a+b;
System.out.println("The Addition of Two No.'s Is :"+res);
}
public void sub()
{
int res,a,b;
System.out.println("Enter a Value to Substract: ");
a=scanner.nextInt();
System.out.println("Enter a Value to Substract: ");
b=scanner.nextInt();
res=a-b;
System.out.println("The Substraction of Two No.'s Is :"+res);
}
public void mul()
{
int res,a,b;
System.out.println("Enter a Value to Multiply: ");
a=scanner.nextInt();
System.out.println("Enter a Value to Multiply: ");
b=scanner.nextInt();
res=a*b;
System.out.println("The Multiplication of Two No.'s Is :"+res);
}
public void div()
{
double res,a,b;
System.out.println("Enter a Value to Numerator: ");
a=scanner.nextInt();
System.out.println("Enter a Value to Denominator: ");
b=scanner.nextInt();
res=a/b;
System.out.println("The Division of Two No.'s Is :"+res);
}
}
public class Calculator_Interface {
public static void main(String[] args) {
Calculator_cal cal;
cal = new calculator();
cal.add();
cal.div();
cal.mul();
cal.sub();
}
}