Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. Print the sum of x and y. (line 18)
  2. Print the difference of x and y. (line 21)
  3. Print the product of x and y. (line 24)
  4. 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:

  1. Read the code in Main.java and see how Mary's 50 cents have vanished.
  2. (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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Personal Finance

Authors: Jeff Madura, Hardeep Singh Gill

4th Canadian edition

134724712, 134724713, 9780134779782 , 978-0134724713

More Books

Students also viewed these Programming questions

Question

What is a second mortgage?

Answered: 1 week ago