Math Expressions Javascript Hw Collaborators_ipynb_2_
Part 2: Arithmetic Practice
Write a Java program to calculate these:
num1 = 10
num2 = 5
sum = num1 + num2
difference = num1 - num2
product = num1 * num2
quotient = num1 / num2
- Display all results using
System.out.println()
.
Example Output:
Sum: 15 Difference: 5 Product: 50 Quotient: 2
Part 3: Step-by-Step Sequencing
Write a Java program that does this sequence:
- Set
num1 = 2
andnum2 = 3
. - Calculate
num3 = num1 + num2
. - Calculate
num4 = num3 * 2
. - Display
num3
andnum4
usingSystem.out.println()
.
This shows sequencing: each step depends on the previous one.
Part 4: Mixed Arithmetic
- Set
a = 8
,b = 4
,c = 2
. - Calculate:
result1 = a + b * c
result2 = (a + b) * c
- Display
result1
andresult2
usingSystem.out.println()
.
This helps practice order of operations.