Question: Below is a list of things that your program should do and the exact order in which they should be done: Declare two integers (call
Below is a list of things that your program should do and the exact order in which they should be done:
- Declare two integers (call them firstNumber and secondNumber) and assign them some values of your choice (1 pt).
- Compute the result of dividing firstNumber by secondNumber; store it in an int variable. Display the result (2 pts).
- Compute the result of dividing firstNumber by secondNumber; store it in a double variable. Display the result (2 pts).
- Compute the result of casting firstNumber to a double, then dividing by secondNumber; store it in a double variable. Display the result (2 pts).
- Compute the result of dividing firstNumber by secondNumber and then casting to a double (use parentheses to force the order of operations); store it in a double variable. Display the result (2 pts).
- Explain the results that you observed in steps 2-5. Why did some of the answers give the correct mathematical result, and others did not? Write your explanation in the comments of the program. (2 pts).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
