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

Need this written in C++. and to be as simple as you can The Sun Furnace Company

ID: 3935404 • Letter: N

Question

Need this written in C++. and to be as simple as you can

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 an additional $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

Verify the follwing test cases:

Service Type Minutes Furnace Type Shift Bill Amount S 25 G $100.00 S 50 G $114.25 S 25 N $125.00 S 50 N $139.25 D 20 G Day $25.00 D 50 G Day $34.60 D 20 N Day $40.00 D 50 N Day $49.60 D 10 G Night $25.00 D 30 G Night $33.40 D 10 N Night $40.00 D 30 N Night $48.40

Explanation / Answer

Given sample examples seem to be wrong when compared to the problem statement.

Following is the code according to the given problem statement:

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

void printWelcomeMessage(){
   cout << "Welcome to Sun Furnace Bill calculator" << endl;
   cout << "You will be asked for the following information :" << endl;
   cout << "* Service Type (S,s,D,d)" << endl;
   cout << "* Furnace Type (G,g for gas, O,o for non gas)" << endl;
   cout << "* Service Minutes" << endl;
   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." << endl;
   cout << endl;
   return;
}

double billingAmountForStandardService( char furnaceType, int servicesMinutes ){
   double result = 100;
   if( servicesMinutes > 30 ){
       result += (servicesMinutes- 30)*0.75;
   }
   if( furnaceType == 'O' || furnaceType == 'o' ){
       result += 25;
   }
   return result;
}

double billingAmountForDeluxeService( char furnaceType, int servicesMinutes, char serviceShift ){
   double result = 25;
   if( serviceShift == 'D' || serviceShift == 'd' ){
       if( servicesMinutes > 25 ){
           result += ( servicesMinutes - 25 )*0.40;
       }
   }
   if( serviceShift == 'N' || serviceShift == 'n' ){
       if( servicesMinutes > 15 ){
           result += ( servicesMinutes - 15 )*0.60;
       }
   }
   if( furnaceType == 'O' || furnaceType == 'o' ){
       result += 15;
   }
   return result;
}

void printBill( char serviceType, char furnaceType, char serviceShift, int servicesMinutes,
       double billAmount )
{
   cout << serviceType << " " << furnaceType << " " << serviceShift << " " << servicesMinutes << endl;
   cout << "Customer Bill" << endl;
   cout << "Service Type : ";
   if( serviceType == 'D' || serviceType == 'd' ){ cout << "Deluxe "; }
   if( serviceType == 'S' || serviceType == 's' ){ cout << "Standard "; }
   cout << "Furnace Type : ";
   if( furnaceType == 'G' || furnaceType == 'g' ){ cout << "Gas" << endl; }
   if( furnaceType == 'O' || furnaceType == 'o' ){ cout << "Non Gas" << endl; }
   cout << "Service Shift : ";
   if( serviceShift == 'D' || serviceShift == 'd' ){ cout << "Day "; }
   if( serviceShift == 'N' || serviceShift == 'n' ){ cout << "Night "; }
   cout << "Minutes : " << servicesMinutes << endl;
   cout << "Bill Amount : $ ";

   cout << fixed << setprecision(2);
   cout << billAmount << endl;
}

int main(){
   printWelcomeMessage();
   char serviceType, furnaceType;
   int servicesMinutes;
   char serviceShift;

   cout << "Enter service type (S,s,D,d) : ";
   cin >> serviceType;
   cout << "Enter furnace type (G,g for gas, O,o for non gas) : ";
   cin >> furnaceType;
   cout << "Enter service minutes : ";
   cin >> servicesMinutes;
   if( serviceType == 'D' || serviceType == 'd' ){
       cout << "Enter service shift: (D,d,N,n) : ";
       cin >> serviceShift;
   }

   double billAmount = 0;
   if( serviceType == 'S' || serviceType == 's' ){
       billAmount = billingAmountForStandardService( furnaceType, servicesMinutes );
   }
   if( serviceType == 'D' || serviceType == 'd' ){
       billAmount = billingAmountForDeluxeService( furnaceType, servicesMinutes , serviceShift );
   }
   printBill( serviceType, furnaceType, serviceShift, servicesMinutes, billAmount );

   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote