Answered step by step
Verified Expert Solution
Link Copied!

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:

7. 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 name)s 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 =2 x Trip fuel cost
i) You need to convert this mathematical formula to a Java statement!
(h) Display Thank you for using (your name)s fuel cost calculator.
8. Compile and test the program to make sure it works (see the Example Input and Output section below.
9. Hand in the source file:
(a) In the D2L page for this course, under Tasks click on Assignments.
(b) Click on the Assignment labeled Assignment 1 to upload your source file.
(c) To find the source file, go to the location that you used to create your project in step 3.
(d) Open the YourlastnameAssign1 folder.
(e) Open the src folder.
(f) Open the main folder.
(g) Open the java folder.
(h) Open the csci1010 folder.
(i) Open the YourLastNameassign1 folder.
(j) There should be a file in this folder called YourlastnameAssign1.java, 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 1:
Welcome to Kriti Chauhan's fuel cost calculator.
Enter name of destination
Gatlinburg
Enter distance to Gatlinburg (in miles):
268.1
Enter fuel efficiency of your car (in mpg):
28.3
9.47 gallons of fuel are required to get to Gatlinburg
Enter gas price in your area (in $/gallon):
2.88
Fuel cost for trip to Gatlinburg is: $27.28
Fuel cost for a round trip is: $54.57
Thank you for using Kriti's fuel cost calculator!
------------------------------------------------------------------------
Note that in the example aboveGatlinburg,268.1,28.3, and 2.88 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 1. The name of the source file must be your last name followed by Assign1 with the extension .java. For example, mine would be DanaAssign1.java.
Make sure to include comments with your name, a description of what the program does, the course (CSCI 1010), and the assignment name (Programming Assignment 1) 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

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

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

Students also viewed these Databases questions

Question

3. How has e-commerce transformed marketing?

Answered: 1 week ago