Question: CSE 1 3 8 4 - C + + Basics Lab 2 Objectives: Practice getting input from the user Practice using loops and conditions Assignment:

CSE 1384- C++ Basics
Lab 2
Objectives:
Practice getting input from the user
Practice using loops and conditions
Assignment:
In this lab you'll be building a tool to allow people to compare their vehicles. So, basically, assume a family has multiple vehicles they're able to use and they're trying to decide which vehicle would be best to use on a road trip.
Your job is to create a program that takes in how many miles their trip is supposed to be and the average gas price of their journey. You should then ask how many vehicles they'd like to compare. While looping, ask the names (make and model) of each vehicle and their gas mileage and tank capacity. After receiving the information, calculate how many tanks of gas it would take for each vehicle and what the projected price would be for the journey. Display this information to the user.
Your price should be based on how much it is to fill up a full tank on each individual vehicle. You shouldn't just calculate how many gallons that car would need and then calculate that cost. You also cannot have PARTIAL tanks. If it's 2.1 tanks, you should display 3 tanks and calculate it for 3 tanks.
Finally, at the end of the program, you should display the best name / cost of the car based on the calculations.
Hint:
To make 2.1 into 3, there's a couple ways to do so. One such way involves the cmath library and using the ceil function.
Milestones:
You must receive a check-off for each item to receive full credit on the lab. You may show the milestones incrementally, or receive a check off for multiple in one demo depending on your progress.
Examples of each milestone are included.
Milestone 1:
Receiving initial data and setting up the loop. Must show:
Distance, gas price, and number of vehicles compared
Looping the number the user entered
Your loop only has to show "car 1, car 2..." etc for however many cars they entered at this stage
Numbering SHOULD start at 1, not 0
Welcome to the mileage calculator!
How far (in miles) will you be traveling? 1250
What is the average gas price for your journey? 1.99
How many cars are you comparing? 4
car 1
car 2
car 3
car 4
Milestone 2:
Accept unique data for each car. Must show:
Input for each car (make/model, mpg, and tank capacity)
Display that information back to the user to show proper storage
How many cars are you comparing? 2
Enter the make and model of car 1: Mazda CX5
Enter in the MPG (miles per gallon): 30
Enter in the tank capacity (in gallons): 13
Mazda CX5 has 30mpg and a 13 gallon capacity tank.
Enter the make and model of car 2: Lincoln Zephyr
Enter in the MPG (miles per gallon): 19
Enter in the tank capacity (in gallons): 17
Lincoln Zephyr has 19mpg and a 17 gallon capacity tank.
Milestone 3:
Do the math. Must show:
Proper gas tank numbers wi
How many cars are you comparing? 2
Enter the make and model of car 1: Lincoln Zephyr
Enter in the MPG (miles per gallon): 19
Enter in the tank capacity (in gallons): 17
Your Lincoln Zephyr will need 4 tanks.
This will cost $135.32
Enter the make and model of car 2: Mazda CX5
Enter in the MPG (miles per gallon): 30
Enter in the tank capacity (in gallons): 13
Your Mazda CX5 will need 4 tanks.
This will cost $103.48
Milestone 4:
Store the make/model and overall price of the best car for the trip to display at the end of the loop. Must show:
Correct car make/model and price
Hint: To work, make sure you're considering local/global scope as it applies to loops for your variables. On the very FIRST loop through, consider setting the values you're designating as the "best" to immediately be the make/model and cost of the first car. This way, you have something to compare it to on subsequent loops.
Welcome to the mileage calculator!
How far (in miles) will you be traveling? 1250
What is the average gas price for your journey? 1.99
How many cars are you comparing? 3
Enter the make and model of car 1: Mazda 3
Enter in the MPG (miles per gallon): 23
Enter in the tank capacity (in gallons): 13
Your Mazda 3 will need 5 tanks.
This will cost $129.35
Enter the make and model of car 2: Mazda CX5
Enter in the MPG (miles per gallon): 30
Enter in the tank capacity (in gallons): 13
Your Mazda CX5 will need 4 tanks.
This will cost $103.48
Enter the make and model of car 3: Lincoln Zephyr
Enter in the MPG (miles per gallon): 19
Enter in the tank capacity (in gallons): 17
Your Lincoln Zephyr will need 4 tanks.
This will cost $135.32
Your best option is the Mazda CX5 at $103.48
Comment Block:
Your code should contain a comment block at the top containing information on who wrote the code, what the assignment is, when it is due, etc. Here is an example of a good comment block to put:
/*
Name: th ceiling principles applied
Correct prices
 CSE 1384- C++ Basics Lab 2 Objectives: Practice getting input from

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!