-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicMath.java
More file actions
39 lines (31 loc) · 1.41 KB
/
BasicMath.java
File metadata and controls
39 lines (31 loc) · 1.41 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
import java.util.Scanner;
public class BasicMath {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the first integer value: ");
int int1 = scanner.nextInt();
System.out.print("Enter the second integer value: ");
int int2 = scanner.nextInt();
System.out.println("Sum of the values: " + (int1 + int2));
System.out.println("Difference of the values: " + (int1 - int2));
System.out.println("Product of the values: " + (int1 * int2));
if (int2 != 0) {
System.out.println("Quotient of the values: " + ((double) int1 / int2));
} else {
System.out.println("Division by zero is not allowed.");
}
System.out.print("\nEnter first doubl value: ");
double double1 = scanner.nextDouble();
System.out.print("Enter second double value: ");
double double2 = scanner.nextDouble();
scanner.close();
System.out.println("Sum of the values: " + (double1 + double2));
System.out.println("Difference of the values: " + (double1 - double2));
System.out.println("Product of the values: " + (double1 * double2));
if (double2 != 0) {
System.out.println("Quotient of the values: " + (double1 / double2));
} else {
System.out.println("Division by zero is not allowed.");
}
}
}