Question
You will want a calculator as you work through this homework assignment. Consider the Java program shown below. (The Java program can also be found
You will want a calculator as you work through this homework assignment.
Consider the Java program shown below. (The Java program can also be found in the file FunJavaMath.txt in Talon as well.)
By hand/calculator, work through the program and calculate the resulting values as a Java program would calculate them. Record the five values that it would print out next to the corresponding labels in the column of the table provided below.
Copy the program into BlueJ (or similar Java programming environment), compile, and run the program. Record the five values that the Java program actually prints out next to the corresponding labels in the column of the table provided below.
If there are any differences between the two results, you should leave your answers as they are, but write a short explanation of the difference in the final column of the table. This explanation is generally going to state something about how Java does calculations, or a concept that you may have forgotten to apply in your first calculation.
Program Label | By Hand Result | Program Result | Explanation if Different |
Difference: |
|
|
|
Sum: |
|
|
|
Product: |
|
|
|
Quotient: |
|
|
|
Remainder: |
|
|
|
public class FunJavaMath
{
public static void main (String [] args)
{
int x = 75;
int y = 23;
int z = 42;
System.out.println("Follow along with the math!");
System.out.println("Difference: " + (y-x));
System.out.println("Sum: " + (x+y+z));
System.out.println("Product: " + (y*z));
System.out.println("Quotient: " + (z/x));
System.out.println("Remainder: " + (z%y));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started