Answered step by step
Verified Expert Solution
Question
1 Approved Answer
7 . Rewrite your program so it calculates the fuel needed and total fuel cost of a trip. The program will perform the following tasks:
Rewrite your program so it calculates the fuel needed and total fuel cost of a trip. The program will perform the following tasks:
a Display Welcome to your names fuel cost calculator.
b Ask the user to enter name of a trip destination.
c Ask the user to enter the distance to that trip destination in miles and the fuel efficiency of their car in mpg or miles per gallon
d Calculate the fuel required to get to destination and display it
i Use the formula: Fuel amount Distance Fuel efficiency, where Fuel is in gallons, Distance is in miles and Fuel efficiency is in miles per gallon.
ii Your program should follow Java convention for variable names camelCase
e Ask the user to enter fuel price in dollars per gallon in their area.
f Compute trip cost to get to destination and display it
i Use the formula: Trip fuel cost Fuel amount x Fuel price, where trip fuel cost is in dollar amount, fuel is in gallons, and fuel price is in dollars per gallon.
ii You need to convert this mathematical formula to a Java statement. Be sure to use the right operator symbols! And, as before, follow Java convention for variables names camelCase
g Compute and display total fuel cost for round trip, to reach and return from destination, using the formula: Round Trip Fuel Cost x Trip fuel cost
i You need to convert this mathematical formula to a Java statement!
h Display Thank you for using your names fuel cost calculator.
Compile and test the program to make sure it works see the Example Input and Output section below.
Hand in the source file:
a In the DL page for this course, under Tasks click on Assignments.
b Click on the Assignment labeled Assignment to upload your source file.
c To find the source file, go to the location that you used to create your project in step
d Open the YourlastnameAssign folder.
e Open the src folder.
f Open the main folder.
g Open the java folder.
h Open the csci folder.
i Open the YourLastNameassign folder.
j There should be a file in this folder called YourlastnameAssignjava, except with your last name.
k Upload this file to the assignment folder. DO NOT UPLOAD ANY OTHER FILES!
Example Input and Output
When you test your program the output should look like the following examples, except that your name should be used in place of mine.
Example Run :
Welcome to Kriti Chauhan's fuel cost calculator.
Enter name of destination
Gatlinburg
Enter distance to Gatlinburg in miles:
Enter fuel efficiency of your car in mpg:
gallons of fuel are required to get to Gatlinburg
Enter gas price in your area in $gallon:
Fuel cost for trip to Gatlinburg is: $
Fuel cost for a round trip is: $
Thank you for using Kriti's fuel cost calculator!
Note that in the example aboveGatlinburg and are user input and the rest of the information is output by the program.
Notes and Comments
Upload your Java source file to the assignment named Programming Assignment The name of the source file must be your last name followed by Assign with the extension java. For example, mine would be DanaAssignjava.
Make sure to include comments with your name, a description of what the program does, the course CSCI and the assignment name Programming Assignment at the beginning of your source file.
Make sure you only hand in the source file for your assignment, not the class file, or any other files that NetBeans creates.
Your programs must compile without errors in order to be graded. Once your program compiles make sure to test it using multiple different test cases to see if it meets the requirements of the assignment.
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