-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCalculator.java
More file actions
39 lines (39 loc) · 851 Bytes
/
Copy pathCalculator.java
File metadata and controls
39 lines (39 loc) · 851 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
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.*;
public class Main
{
public static int add(int a,int b)
{
int ans=0;
ans=a+b;
return ans;
}
public static int sub(int a,int b)
{
int ans=0;
ans=a-b;
return ans;
}
public static int mul(int a,int b)
{
int ans=0;
ans=a*b;
return ans;
}
public static float div(int a,int b)
{
float ans=0;
ans=a/b;
return ans;
}
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int x=in.nextInt();
int y=in.nextInt();
System.out.println("Sum: "+add(x,y));
Main main=new Main(); //object or instance creation for class main
System.out.println("Difference: "+main.sub(x,y));
System.out.println("Product: "+main.mul(x, y));
System.out.println("Division: "+main.div(x,y));
}
}