-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmathoperations.java
More file actions
43 lines (36 loc) · 1.24 KB
/
mathoperations.java
File metadata and controls
43 lines (36 loc) · 1.24 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
import java.util.Scanner;
public class mathoperations {
static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
double total = 0;
int num1;
int num2;
System.out.print("Enter a first number: ");
num1 = s.nextInt();
System.out.print("Enter a second number: ");
num2 = s.nextInt();
System.out.println("\nThe sum is: " + add(num1, num2, total));
System.out.println("The difference is: " + subtract(num1, num2,
total));
System.out.println("The product is: " + multiply(num1, num2,
total));
System.out.println("The qoutient is: " + divide(num1, num2,
total));
}
public static double add(int num1, int num2, double total) {
total = num1 + num2;
return total;
}
public static double subtract(int num1, int num2, double total) {
total = num1 - num2;
return total;
}
public static double multiply(int num1, int num2, double total) {
total = num1 * num2;
return total;
}
public static double divide(int num1, int num2, double total) {
total = num1 / num2;
return total;
}
}