-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path006-Arithmetic-Operators.java
More file actions
75 lines (60 loc) · 2.49 KB
/
Copy path006-Arithmetic-Operators.java
File metadata and controls
75 lines (60 loc) · 2.49 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* ============================================================================
* Program Name : Arithmetic Operators
* File Name : 006-Arithmetic-Operators.java
* Class Name : ArithmeticOperators
*
* Description:
* This program demonstrates the use of arithmetic operators in Java.
* Arithmetic operators are used to perform mathematical operations
* such as addition, subtraction, multiplication, division, and modulus.
*
* Arithmetic Operators:
* + Addition
* - Subtraction
* * Multiplication
* / Division
* % Modulus (Remainder)
*
* Objective:
* - Understand arithmetic operators in Java.
* - Perform basic mathematical calculations.
* - Display the result of each arithmetic operation.
*
* Author : Shaik Mahaboob Basha
* Repository : 01-Core-Java
* Folder : 08-Java-Programs
* ============================================================================
*/
public class ArithmeticOperators {
// The main() method is the entry point of every Java application.
public static void main(String[] args) {
// Declare and initialize the first integer variable.
int number1 = 20;
// Declare and initialize the second integer variable.
int number2 = 6;
// Perform addition.
int addition = number1 + number2;
// Perform subtraction.
int subtraction = number1 - number2;
// Perform multiplication.
int multiplication = number1 * number2;
// Perform integer division.
int division = number1 / number2;
// Find the remainder using the modulus operator.
int modulus = number1 % number2;
// Print the values of both numbers.
System.out.println("First Number : " + number1); // Output: First Number : 20
System.out.println("Second Number : " + number2); // Output: Second Number : 6
// Print the addition result.
System.out.println("Addition : " + addition); // Output: Addition : 26
// Print the subtraction result.
System.out.println("Subtraction : " + subtraction); // Output: Subtraction : 14
// Print the multiplication result.
System.out.println("Multiplication : " + multiplication); // Output: Multiplication : 120
// Print the division result.
System.out.println("Division : " + division); // Output: Division : 3
// Print the modulus result.
System.out.println("Modulus : " + modulus); // Output: Modulus : 2
}
}