Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++, The Sun Furnace Company provides furnace repair service to residential c

ID: 3930158 • Letter: I

Question

In C++,

The Sun Furnace Company provides furnace repair service to residential customers. It has asked you to develop a program that calculates and outputs a customer's bill. The company offers 2 types of service: Standard and Deluxe. Its rates vary, depending on the type of service. Rates are computed as follows :

Standard service :  $100.00 plus first 30 free service minutes. Charges for over 30 service minutes are $0.75 per minute. If the furnace is not fueled by natural gas, there is anadditional $25 charge.

Deluxe service :   $25.00 plus :

a. For service starting between 8:00 a.m. and 4:00 p.m. the first 25 service minutes are free; charges for more than 25 minutes are $0.40 per minute.

b. For service starting between 4:01 p.m. and 7:59 a.m. the first 15 service minutes are free; charges for more than 15 minutes are $0.60 per minute.   

c. If the furnace is not fueled by natural gas, there is an additional $15 charge.

The program MUST use 4 functions :

- A void function which outputs the following :

Welcome to Sun Furnace Bill calculator

You will be asked for the following information :

* Service Type (S,s,D,d)

* Furnace Type (G,g for gas, O,o for non gas)

* Service Minutes

* Service Shift (D,d indicates service started between 8 a.m. and 4 p.m. N, n indicates service started between 4:01 p.m. and 7:59 a.m. This is only asked if the service type is Deluxe.

- A value returning function which calculates and returns the billing amount for standard service.  

- A value returning function which calculates and returns the billing amount for Deluxe service.

- A void function which outputs the bill. For example  :

Customer Bill

Service Type : Deluxe Furnace Type : Gas

Service Shift : Day Minutes : 80

Bill Amount : $ 55.00

Explanation / Answer

SOURCE CODE:

#include<iostream>
using namespace std;
class furnace{
   public:
       char serviceType;
       char furnaceType;
       int serviceMinutes;
       char serviceShift;
   furnace(char st,char ft,int sm,char ss)
   {
       char serviceType = st;
       char furnaceType = ft;
       int serviceMinutes = sm;
       char serviceShift = ss;
   }
   furnace()
   {
   }
   double deluxeService()
   {
       double charge=25.00;
  
       if(furnaceType=='o' || furnaceType=='O')
           charge = charge + 25.00;
      
       if(serviceShift=='D' || serviceShift=='d')
       {
           if(serviceMinutes>25)
               charge = charge + (charge-25.0)*0.4;      
       }
       else if(serviceShift=='N' || serviceShift=='n')
       {
           if(serviceMinutes>15)
               charge = charge + (charge-15.0)*0.4;      
       }
       return charge;      
   }  
   double standardService()
   {
       double charge=100.00;
       if(furnaceType=='o' || furnaceType=='O')
           charge = charge + 25.00;
       if(serviceMinutes>30)
           charge = charge + (charge-30.0)*0.75;
       return charge;
   }
   void welcome()
   {
       cout<<" Welcome to Sun Furnace Bill calculator";
       cout<<" You will be asked for the following information :";
       cout<<" * Service Type (S,s,D,d)";
       cout<<" * Furnace Type (G,g for gas, O,o for non gas)";
       cout<<" * Service Minutes";
       cout<<" * Service Shift (D,d indicates service started between 8 a.m. and 4 p.m. N, n indicates service started between 4:01 p.m. and 7:59 a.m. This is only asked if the service type is Deluxe.";
   }
   void generateBill()
   {
      
       if(serviceType=='d' || serviceType=='D')
           cout<<" Service Type :Deluxe ";
       else if(serviceType=='s' || serviceType=='S')
           cout<<" Service Type :Standard ";
       if(furnaceType=='g' || furnaceType=='G')
           cout<<" Furnace Type : Gas";
       else if(furnaceType=='o' || furnaceType=='O')
           cout<<" Furnace Type : Others";
          
       if(serviceType=='d' || serviceType=='D')
       {
           if(serviceShift=='d' || serviceShift=='D')
               cout<<" Service Shift : Day";
           else if(serviceShift=='n' || serviceShift=='N')
               cout<<" Service Shift : Night";
       }
      
       cout<<" Minutes :"<<serviceMinutes;
      
       if(serviceType=='d' || serviceType=='D')
           cout<<" Bill Amount : $"<<deluxeService();
       else if(serviceType=='s' || serviceType=='S')
           cout<<" Bill Amount : $"<<standardService();
   }
};

int main()
{
   furnace f1;
   char ss,ft,st;
   double sm = 0.0;
   f1.welcome();
   cout<<" ";
   cout<<" * Enter Service Type (S,s,D,d) :";
   cin>>st;
   cout<<" * Enter Furnace Type (G,g for gas, O,o for non gas) :";
   cin>>ft;
   cout<<" * Enter Service Minutes :";
   cin>>sm;
  
   if(st=='d' || st=='D')
   {
       cout<<" * Enter Service Shift (D,d,N,n ):";
       cin>>ss;
   }
  
   f1.furnaceType = ft;
   f1.serviceMinutes = sm;
   f1.serviceType = st;
   f1.serviceShift = ss;
   f1.generateBill();
   return 1;
}

OUTPUT:


Welcome to Sun Furnace Bill calculator
You will be asked for the following information :
* Service Type (S,s,D,d)
* Furnace Type (G,g for gas, O,o for non gas)
* Service Minutes
* Service Shift (D,d indicates service started between 8 a.m. and 4 p.m.
N, n indicates service started between 4:01 p.m. and 7:59 a.m.
This is only asked if the service type is Deluxe.


* Enter Service Type (S,s,D,d) :S

* Enter Furnace Type (G,g for gas, O,o for non gas) :G

* Enter Service Minutes :45

Service Type :Standard
Furnace Type : Gas
Minutes :45
Bill Amount : $152.5
--------------------------------

You will be asked for the following information :
* Service Type (S,s,D,d)
* Furnace Type (G,g for gas, O,o for non gas)
* Service Minutes
* Service Shift (D,d indicates service started between 8 a.m. and 4 p.m.
N, n indicates service started between 4:01 p.m. and 7:59 a.m.
This is only asked if the service type is Deluxe.


* Enter Service Type (S,s,D,d) :D

* Enter Furnace Type (G,g for gas, O,o for non gas) :O

* Enter Service Minutes :67

* Enter Service Shift (D,d,N,n ):N

Service Type :Deluxe
Furnace Type : Others
Service Shift : Night
Minutes :67
Bill Amount : $64
--------------------------------