Question
Show how to do simple math operations to int values. The values of int x and int y will be asked for in the console
Show how to do simple math operations to int values. The values of int x and int y will be asked for in the console when you run the application yourself. You will have to put in two numbers you want to use. However, for the test you just have to provide the code for printing out the sum, difference, product and quotient for x and y. Please follow the steps below:
Steps:
- Print the sum of x and y. (line 18)
- Print the difference of x and y. (line 21)
- Print the product of x and y. (line 24)
- Print the quotient of x and y. (line 27)
Test:
Use the test provided. This test accounts for the print statements.
Sample:
Input:
102
Output:
What numbers would you like to do math with?128205
2, Description:
This activity will help you understand how casting data types works in Java. Mary initially has $6.50 as a float value. However She deposits it into a bank and the bank can only handle integer values. The bank now registers only $6. The 50 cents have disappeared. Please follow the steps below:
Steps:
- Read the code in Main.java and see how Mary's 50 cents have vanished.
- (Find this instruction on line 17 in Main.java) Try adding an integer value to a float value. You don't need to do the casting yourself because the float value is larger and the conversion from int to float happens automatically! Use an integer of 10 and a float of 3.755. Add them and print the result.
Test:
Use the test provided. The test accounts for the print outs from Mary's case.
Sample output:Mary started with: 6.5. This is the amount the bank registered: 613.755
Step by Step Solution
3.46 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Certainly Below is a simple Java code that demonstrates how to perform basic arithmetic operations o...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