Question

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: Hey!! Dear student kindly finds your solution below. Let me know if any issue. Thanks.

This C++ program takes necessary inputs, all calculations are done in this and print desired output as you mentioned in the problem.

#include<iostream>
using namespace std;
int main()
{

double REGULAR = 2.89,PLUS = 3.09,SUPER = 3.39;
char gas_type,car_wash;
double price,no_gallons,carwash_cost,total_price,type_price;
cout<<"Enter number of gallons and press<Enter>";
cin>>no_gallons;
cout<<"\nEnter gas type(R,P,S, or N) and press<enter>";
cin>>gas_type;
cout<<"\nEnter Y or N for car wash and press<enter>";
cin>>car_wash;
if(gas_type == 'R')
{
type_price = REGULAR;
price = no_gallons*REGULAR;
}
else
if(gas_type == 'P')
{
type_price = PLUS;
price = no_gallons*PLUS;
}
else
if(gas_type == 'S')
{
type_price = SUPER;
price = no_gallons*SUPER;
}
else
{
price = 0;
}
if(car_wash == 'Y')
{
if(price>10)
{
carwash_cost = 1.25;
}
else
{
carwash_cost = 3.00;
}
}
else
if(car_wash == 'N')
{
carwash_cost = 0;
}
total_price = price+carwash_cost;
cout<<"\n******************************************"<<endl;
cout<<"* *"<<endl;
cout<<"* *"<<endl;
cout<<"* Gas-N-Clean Service Station *"<<endl;
cout<<"*               *"<<endl;
cout<<"*   March 2,2004   *"<<endl;
cout<<"*               *"<<endl;
cout<<"*******************************************";
cout<<"\nAmount Gasoline purchases   "<<no_gallons<<"Gallons";
cout<<"\nPrice per gallons $ "<<type_price;
cout<<"\nTotal gasoline cost $ "<<price;
cout<<"\nCar wash cost $ "<<carwash_cost;
cout<<"\nTotal due $ "<<total_price;

cout<<"\n\nThank you for stopping";
cout<<"\nPlease come again";
cout<<"\nRemember to buckle up and drive safety";
return 0;
}

Ouput:

Enter Y or N for car wash and press<enter> Gas-N-Clean Service Station * March 2, 2004 $ Amount Gasoline purchases Price per gallons Total gasoline cost Car wash cost Total due 9.7Gallons 2.89 28.033 1.25 29.283 Thank you for stopping Please come again Remember to buckle up and drive safety tus

Add a comment
Know the answer?
Add Answer to:
The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm a C++ beginner, I'm not sure how to do this. Calculate the amount a customer...

    I'm a C++ beginner, I'm not sure how to do this. Calculate the amount a customer should be charged at a gas station. Fees for the car wash are $4.25 with gasoline purchase of $35.00 or more and $10.00 otherwise. Three kinds of gasoline are available: regular at 3.39, unleaded at 3.55 and premium at 3.65 per gallon. Input consists of the customer number, number of gallons purchased, kind of gasoline purchased (R, U, P, or, for no purchase, N),...

  • please do the program in simple programming it is for my first c++ computer class i...

    please do the program in simple programming it is for my first c++ computer class i posted the example on pic 2,3 which is how this should be done Write a program that calculates and prints the bill for a cellular telephone company. The company offers two types of services: regular and premium. Its rates vary depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus the first 50 minutes are free. Charges for...

  • The manager of a gas station decided to identify his customers' demand curve for gasoline of...

    The manager of a gas station decided to identify his customers' demand curve for gasoline of in order to improve the profitability of his gas station. For this reason he collected data during a three months interval of time and on this basis created the following table indicating the relationship between the price of a gallon of gasoline and the average number of gallons sold per day: Price    Number of gallons $2.09 2143 $2.19 2081 $2.29 2097 $2.39 2006...

  • I have this class determines how much petrol is being purchased and the cost. The gas...

    I have this class determines how much petrol is being purchased and the cost. The gas is divided between regular, premium, and super unleaded. The program reads (R, P, or S) that designates which kind of gasoline was purchased. class Petrol { private static final double Premium = 0; private static final double Super = 0; char gas; String type; double amount, cost; private String free; private double regular; Petrol(char ch, double a) { gas = ch; amount = a;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT