Question: Do the following exercise, using jGrasp: Write a program that prompts the user to enter the distance to drive, the fuel efficiency of the car
Do the following exercise, using jGrasp:
Write a program that prompts the user to enter the distance to drive, the fuel efficiency of the car in miles per gallon, and the price per gallon, and displays the cost of the trip.
Here is a sample run (the first three numbers are entered by the user, your program calculates the cost of driving):
Enter the driving distance: 900.5 Enter the miles per gallon: 25.5 Enter price per gallon: 3.55 The cost of driving is $125.36
You do not need to validate input (you may assume the user always enters positive numbers).
Don't forget to add comments to your code and use proper programming style.
3. Name your class A2 (that is an uppercase A followed by the number 2).
4. Save your Java file as: A2.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
