-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.java
51 lines (48 loc) · 953 Bytes
/
Calculator.java
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
class Calculator
{
float num1, num2;
void showNumbers()
{
System.out.println("The first number is "+num1+" and the second number is "+num2);
}
void add()
{
float sum=num1+num2;
System.out.println("The addition of the numbers is: "+sum);
}
void substract()
{
float minus=num1-num2;
System.out.println("The difference between num1 and num2 is: "+minus);
}
void mul()
{
float mult=num1*num2;
System.out.println("The product of the two numbers is: "+mult);
}
void div()
{
float divd=num1/num2;
System.out.println("The division results in: "+divd);
}
void mod()
{
float modu=num1%num2;
System.out.println("The modulus is: "+modu);
}
public static void main(String[] args)
{
Calculator c1=new Calculator(10,20);
c1.showNumbers();
c1.add();
c1.substract();
c1.mul();
c1.div();
c1.mod();
}
Calculator(float a, float b)
{
num1=a;
num2=b;
}
}