-
Notifications
You must be signed in to change notification settings - Fork 0
/
Super.java
57 lines (53 loc) · 1.39 KB
/
Super.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
52
53
54
import java.util.Scanner;
class Super{
int num_1,num_2;
}
class calc extends Super{
calc(int a,int b){
super.num_1=a;
super.num_2=b;
}
void Add(){
System.out.print("Addition is:");
System.out.print(num_1+num_2);
}
void Sub(){
System.out.print("Substarction is:");
System.out.print(num_1-num_2);
}
void Mul(){
System.out.print("Multiplication is:");
System.out.print(num_1*num_2);
}
void Div(){
System.out.print("Division is:");
System.out.print(num_1/num_2);
}
}
class Supercalc{
public static void main(String[] args) {
try (Scanner Sc = new Scanner(System.in)) {
System.out.print("Enter Number 1 : ");
int P=Sc.nextInt();
System.out.print("Enter number 2 : ");
int Q=Sc.nextInt();
calc obj=new calc(P,Q);
System.out.println("Enter operation \n1.ADDITION \n2.SUBSTRACTION \n3.MULTIPLICATION \n4.DIVISION : ");
int c=Sc.nextInt();
if (c==1){
obj.Add();
}
else if (c==2){
obj.Sub();
}
else if (c==3){
obj.Mul();
}
else if(c==4){
obj.Div();
}
else
System.out.println("Error:Enter correct input");
}
}
}