Time: 15 minutes
Purpose: This activity helps you get familiar with using double number operators
Introduction: You’ve seen how to add two decimal numbers together - do you think you can try a few operations on your own?
Task: Perform the following operations on double variables and print the results,
- Divide one integer by another
- Subtract one integer from another
- Multiply one integer by another
double decDivideTotal, devSubtractTotal, devMultiplyTotal;
decDivideTotal = decNum1 / decNum2;
devSubtractTotal = decNum1 - decNum2;
devMultiplyTotal = decNum1 * decNum2;
System.out.println("When we divide " + decNum1 + " by " + decNum2 + " we get: " + decDivideTotal);
System.out.println("When we subtract " + decNum1 + " from " + decNum2 + " we get: " + devSubtractTotal);
System.out.println("When we multiply " + decNum1 + " with " + decNum2 + " we get: " + devMultiplyTotal);