Write a program that asks user for information about where


Programming Project

Submission Instructions

Open Eclipse and create a Java Project called Project1. Add a class named RoadTrip to this project.

At the top of your file, enter a comment with your name, the assignment number, the date, and a short description of what the program does. For example, if I were submitting the assignment my comment might look like this:

/**
* Author: Susanne Sherba
* Programming Project 1
* October 2, 2016
* Calculates gallons of gas needed and number of stops for a road trip.
*/

When you are finished, export your project from Eclipse and upload it to Canvas before the due date. To do this, right click on the project name and select Export. Select General->Archive File and click Next. Select the project you wish to export (Project1 in this case) and click Browse to browse to a location to save your file.

Assignment

You and your friends are planning a road trip. Write a program that asks the user for information about where they are going and the car they are driving and then gives them some helpful information about their trip. Specifically, you should ask the user for:

• the name of the city they are leaving from
• the name of the city they are going to
• the distance between the two cities
• how many miles per gallon their car gets
• how many gallons the car's gas tank holds

You should output the name of the starting and ending cities, the number of gallons of gas the trip requires (with one decimal place) and the number of stops you will need to make along the way (as an integer). Make sure the city names are capitalized, even if the user didn't capitalize them. You may assume that your gas tank is full at the beginning of the trip.

Here's a sample interaction with the user:

Enter city you are leaving from: denver
Enter city you are driving to: jacksonville
Enter distance in miles: 1748
Enter miles per gallon your car gets: 34
Enter the number of gallons your car's tank holds: 15.3

Your trip from Denver to Jacksonville will require 51.4 gallons of gas.

Assuming your gas tank is full when you leave, you will need to stop to fill up 2-3 times.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a program that asks user for information about where
Reference No:- TGS02459256

Now Priced at $35 (50% Discount)

Recommended (94%)

Rated (4.6/5)