Question

In: Computer Science

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash...

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon.


User Request:

Write a program that prints a statement for a customer.


Analysis:

Input consists of number of gallons purchased (R, P, S, or N for no purchase), and car wash desired (Y or N). Gasoline price should be program defined constant. Sample output for these data is


Enter number of gallons and press <Enter> 9.7

Enter gas type (R, P, S, or N) and press <Enter> R

Enter Y or N for car wash and press <Enter> Y


**************************************

* *

* *

* Gas-N-Clean Service Station *

* *

* March 2, 2004 *

* *

**************************************

Amount Gasoline purchases 9.7 Gallons

Price pre gallons $ 2.89

Total gasoline cost $ 28.03

Car wash cost $ 1.25

Total due $ 29.28


Thank you for stopping

Please come again

Remember to buckle up and drive safely

program used is c++

Solutions

Expert Solution

CODE:

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
double numOfGallons;
char gasType, isCarWashNeeded;
double pricePerGallon=0.0,totalGasCost=0.0,costForCarWash=0.0,totalDue;

//constants to hold gasoline price

const double RegularGaslineCost = 2.89;
const double PlusGaslineCost = 3.09;
const double SuperGaslineCost = 3.39;
//read the number of gallons purchased
cout<<"Enter number gallons and press <Enter>: ";
cin>>numOfGallons;
//read the has type
cout<<endl<<"Enter gas type (R,P,S or N) and press <Enter>: ";
cin>>gasType;
//read if car wash is needed or not
cout<<endl<<"Enter Y or N for car wash and press <Enter>: ";
cin>>isCarWashNeeded;

//if gastype is R
if(gasType=='r' || gasType=='R')
{
//calulate total gas cost
totalGasCost=RegularGaslineCost * numOfGallons;   
}
//if gastype is P
else if(gasType=='p' || gasType=='P')
{  
//calulate total gas cost
totalGasCost=PlusGaslineCost * numOfGallons;
}  
//if gastype is S
else if(gasType=='S' || gasType=='s')
{
//calulate total gas cost
totalGasCost=SuperGaslineCost * numOfGallons;   
}
//if gastype is N
else if(gasType=='N' || gasType=='n')
{
//set price per gallon to 0
totalGasCost=0;
}
//else print error message and terminate program  
else
{
cout<<"\nInvalid input. Try again..";
return 0;
}
  
//check if car wash is needed
if(isCarWashNeeded=='Y' || isCarWashNeeded=='y')
{
//if gaa cost is 10 or above
if(totalGasCost>=10)
{
//car wash is 1.25
costForCarWash=1.25;
}
else
{
//else car wash is 3.00
costForCarWash=3.00;
}
}
//if car wash is not needed set wash price to 0
else
{
costForCarWash=0.00;
}
  
//calculate total amount due
totalDue=totalGasCost+costForCarWash;
  
//print the ouput
  
cout<<"\n*****************************************\n";
cout<<"\n*\tGas-N-Cleas Service Station\t*\n";
cout<<"\n*\tMarch 2, 2004\t\t\t*\n";
cout<<"\n*****************************************\n";
cout<<"\nAmount of Gasoline purchase\t"<<numOfGallons<<" Gallons"<<endl;
if(gasType=='R' || gasType=='r')
cout<<"\nPrice per gallon \t\t"<<" $"<<RegularGaslineCost<<endl;
if(gasType=='p' || gasType=='P')
cout<<"\nPrice per gallon \t\t"<<" $"<<setprecision(2)<<PlusGaslineCost<<endl;
if(gasType=='s' || gasType=='S')
cout<<"\nPrice per gallon \t\t"<<" $"<<setprecision(2)<<SuperGaslineCost<<endl;
if(gasType=='n' || gasType=='N')
cout<<"\nPrice per gallon \t\t"<<" $"<<setprecision(2)<<pricePerGallon<<endl;
cout<<"\nTotal gasoline cost\t\t"<<" $"<<fixed<<setprecision(2)<<totalGasCost<<endl;
cout<<"\nCar wash cost\t\t\t"<<" $"<<fixed<<setprecision(2)<<costForCarWash<<endl;
cout<<"\nTotal due\t\t\t"<<" $"<<fixed<<setprecision(2)<<totalDue<<endl;
cout<<endl<<"Thank you for stopping"<<endl;
cout<<endl<<"Please come again"<<endl;
cout<<endl<<"Remember to buckle up and drive safely"<<endl;
return 0;
}

OUTPUT:


Related Solutions

A car wash has two stations, 1 and 2. The service time at station 1 is...
A car wash has two stations, 1 and 2. The service time at station 1 is exponentially distributed with parameter λ1, and the service time at station 2 is exponentially distributed with parameter λ2.When a car arrives at the car wash, it begins service at station 1, provided station 1 is free; otherwise, the car waits until station 1 is available. Upon completing service at station 1, the car then proceeds to station 2, provided station 2 is free; otherwise,...
Auto Clean, a full-service car wash company, is conducting a survey to address the following research...
Auto Clean, a full-service car wash company, is conducting a survey to address the following research objectives: Objective 1. Assess the customer perceptions and evaluations of Auto Clean’s services. Objective 2. Assess the effectiveness of Auto Clean’s promotional expenditures. Objective 3. Identify demographic characteristics of Auto Clean’s customers. Objective 4. Identify other relevant characteristics of Auto Clean’s customers. This is the questionnaire they used for this research: --------------------------------------------------------------------------------------------------------------------- To help us serve you better, please take a few minutes to...
Melanie is the manager of the Clean Machine car wash and has gathered the following information....
Melanie is the manager of the Clean Machine car wash and has gathered the following information. Customers arrive at a rate of eight per hour according to a Poisson distribution. The car washer can service an average of ten cars per hour with service times described by an ex- ponential distribution. Melanie is concerned about the number of customers waiting in line. She has asked you to calculate the following system characteristics: (a) Average system utilization 8/10=0.8= 80% (b) Average...
A full-service car wash has an automated exterior conveyor car wash system that does the initial...
A full-service car wash has an automated exterior conveyor car wash system that does the initial cleaning in a few minutes. However, once the car is through the system, car wash workers hand clean the inside and the outside of the car for approximately 15 to 25 additional minutes. There are enough workers to handle four cars at once during this stage. On a busy day with good weather, the car wash can handle up to 150 cars in a...
Question 1 (6pts) Auto Clean, a full-service car wash company, is conducting a survey to address...
Question 1 (6pts) Auto Clean, a full-service car wash company, is conducting a survey to address the following research objectives: Objective 1. Assess the customer perceptions and evaluations of Auto Clean’s services. Objective 2. Assess the effectiveness of Auto Clean’s promotional expenditures. Objective 3. Identify demographic characteristics of Auto Clean’s customers. Objective 4. Identify other relevant characteristics of Auto Clean’s customers. This is the questionnaire they used for this research: --------------------------------------------------------------------------------------------------------------------- To help us serve you better, please take a...
Question 1 (6pts) Auto Clean, a full-service car wash company, is conducting a survey to address...
Question 1 (6pts) Auto Clean, a full-service car wash company, is conducting a survey to address the following research objectives: Objective 1. Assess the customer perceptions and evaluations of Auto Clean’s services. Objective 2. Assess the effectiveness of Auto Clean’s promotional expenditures. Objective 3. Identify demographic characteristics of Auto Clean’s customers. Objective 4. Identify other relevant characteristics of Auto Clean’s customers. This is the questionnaire they used for this research: --------------------------------------------------------------------------------------------------------------------- To help us serve you better, please take a...
A gas station sells 1500 gallons of gasoline per hour if it charges $ 2.20 per...
A gas station sells 1500 gallons of gasoline per hour if it charges $ 2.20 per gallon but only 1300 gallons per hour if it charges $ 2.95 per gallon. Assuming a linear model (a) How many gallons would be sold per hour of the price is $ 2.25 per gallon? Answer: (b) What must the gasoline price be in order to sell 800 gallons per hour? Answer: $ (c) Compute the revenue taken at the four prices mentioned in...
FMEA (Failure Mode and Effect Analysis) Smelly Gus’s Gas Station sells gasoline. Each non-diesel station carries...
FMEA (Failure Mode and Effect Analysis) Smelly Gus’s Gas Station sells gasoline. Each non-diesel station carries 87, 89, and 93 octane unleaded gasoline. Customers must prepay for gasoline by inserting a credit card or by prepaying with cash inside the station. Instructions Complete a FMEA. Identify the pump’s: function(s), potential failures, potential effects of failures, potential causes of failures, and any possible process controls. Determine Criticality for each potential failure.
It is estimated that amounts of money spent on gasoline by customers at a gas station...
It is estimated that amounts of money spent on gasoline by customers at a gas station in Bristol, Englands, follow a normal distribution with a standard deviation of £3,4. It is also found that 5% of all the customers spent more than £30. What percentage of customers spent less than £25? (explain with steps)
Is a gasoline or gas station an example of monopolistic competition or an example of oligopoly?...
Is a gasoline or gas station an example of monopolistic competition or an example of oligopoly? Why? How can 3 different service station make a profit at the same intersection?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT