Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++ Programming Problem 1: Write a program that calculates a truck's gas mileage and cost for a road trip. Be creative with the output,

IN C++

Programming Problem 1:

Write a program that calculates a truck's gas mileage and cost for a road trip. Be creative with the output, think of it as a report, give it a title at the top and use formatting where appropriate.

The program should set the number of gallons of gas that the truck can hold to 31, and the number of miles it can be driving on a full tank to 651. The program should display the number of gallons the truck can hold, the number of miles it can be driven on a full tank and then display the number of miles that may be driven per gallon of gas.

Next the program should display that the road trip that will be taking place is from Athens, AL to New Orleans, LA. The mileage for the trip is 436.4 miles one way. Gas prices are currently at $2.58 per gallon. You always want to fill up your gas tank when you reach half, 325 miles until empty, which means you have 15.5 gallons of gas left in the truck. Display the total mileage for the round trip, and how much you will spend on gas if you always fill up the tank when you reach its midpoint during the drive there, fill up the tank before leaving LA, and fill up when you reach its midpoint during the drive back to Athens.

Hint: You need to be careful as to how you solve this problem. I suggest solving it by hand first and then writing the code. When you reach New Orleans, you may not be exactly at half a tank (or the 325 miles driven) therefore you need to calculate how much it will cost you to fill up to come back to Athens based on how much gas is still left in the truck once you get there. There is an assumption that once the truck is parked in New Orleans, LA it is not driven again until it is time to drive back to Athens.

Your total expense for gas on this trip should come out to $93.54. Be sure to format your answers correctly with decimals when needed. There may be a few cents difference between our answers depending on how numbers are rounded.

BOOLEAN IS NOT ALLOWED

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

please dont use chat gpt AI 6 3 0 .

Answered: 1 week ago