In: Computer Science
IN C++ LANGUAGE PLEASE::::
Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568 people, it averages about 0.01 gallons per person – (100 miles per gallon per person).
Your job is to design (pseudocode) and implement (source code) a program that asks the user for a distance the plane has to fly (i.e. the length of the trip) and also asks the cost of jet fuel (which is currently $1.80 per gallon). The program should then calculate the total fuel charges to make the trip. Next, ask the user how many people will fly, as well as the average cost of a ticket. Finally, print the total profit made (or lost) and the average gas mileage per person.
pseudocode
const gallonsPerMile=5
tripDistance=Input length of trip in miles
costOfFuel= enter cost of jet fuel per gallon
numberOfpesseger=enter total number of pessenger travel
costPerTicket=enter cost of pessenger ticket
calclate Total Gallons of fuel neede totalGallons=tripDistance*gallonsPerMile;\
calculate total cost of the fuel totalFuelCost=totalGallons*costOfFuel;
calculate total price of the all ticket totalTicketPrice=numberOfpesseger*costPerTicket;
check totalFuelCost is less then totalTicketPrice then profit made and it is totalTicketPrice-totalFuelCost
or if totalFuelCost is greater then totalTicketPrice then loss made and it is totalFuelCost- totalTicketPrice
The average gas mileage per person =totalGallons/numberOfpesseger
code
#include<iostream>
using namespace std;
const int gallonsPerMile=5;
int main()
{
double
tripDistance,costOfFuel,costPerTicket,totalTicketPrice;
double
totalGallons,totalProfitLoss,totalFuelCost;
int numberOfpesseger;
cout<<"Enter the length of the trip in miles:
";
cin>>tripDistance;
cout<<"Enter the cost of jet fuel per gallon:
";
cin>>costOfFuel;
cout<<"Number of pessenger will fly: ";
cin>>numberOfpesseger;
cout<<"Enter the average cost of ticket:
";
cin>>costPerTicket;
totalGallons=tripDistance*gallonsPerMile;
totalFuelCost=totalGallons*costOfFuel;
totalTicketPrice=numberOfpesseger*costPerTicket;
if(totalTicketPrice>totalFuelCost)
{
totalProfitLoss=totalTicketPrice-totalFuelCost;
cout<<"Total profit made:
$"<<totalProfitLoss<<endl;
}
else if(totalTicketPrice<totalFuelCost)
{
totalProfitLoss=totalFuelCost;-totalTicketPrice;
cout<<"Total loss :
$"<<totalProfitLoss<<endl;
}
else
{
cout<<"No profit no loss
made;"<<endl;
}
cout<<"\nThe average gas mileage per person
"<<totalGallons/numberOfpesseger<<endl;
}
output
If you have any query regarding the code please ask me in the
comment i am here for help you. Please do not direct thumbs down
just ask if you have any query. And if you like my work then please
appreciates with up vote. Thank You.