Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I get help with this whole thing in Java form Create an application that calculates the miles per gallon based on the miles driven

Can I get help with this whole thing in Java form

image text in transcribed
Create an application that calculates the miles per gallon based on the miles driven and gallons of gas entered by a user. You will use the Math class and NumberFormat class to see how each affects founding. Console Welcome to the Miles Per Gallon calculator Enter miles driven: 400 Enter gallons of gas used: 15 . 8 Miles per gallon: 25. 32 Calculate another MPG? (y) : Specifications Assume that the user will enter valid double values for the miles driven and gallons used. The application should continue only if the user enters "y" or "Y" to continue. 1. After creating your MPG application, run and test it with a range of values. Note that the miles per gallon value sometimes has several decimal places. For example, after entering 400 miles and 15.8 gallons, the miles per gallon value is 25.31645569620253. 2. Use the round() method of the Math class to round the miles per gallon value to two decimal places. 3. Run your application with 400 miles and 15.8 gallons to make sure the code rounds the miles per gallon correctly by comparing it to the value in step 1. Comment out the lines of code that uses the Math.round() method and output. 5. Modify your application so it uses the NumberFormat class to round the miles per gallon value to two decimal places. 6. Run the application with 400 miles and 15.8 gallons again. Compare the miles per gallon value to the value used in step 1. How does the NumberFormat rounding compare to the Math.round() values

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions