Answer to Question #124409 in C++ for emmanuel

Question #124409
Write a program that computes the total ticket sales of a concert . there are three types of seating’s : A, B, and C. the program accepts the number of tickets sold and the price of a ticket for each of the three types of seats. The total sales are computed as
totalSales = numberofA_Seats * priceperA_Seat +
numberofB_Seats * priceperB_Seat +
numberofC_Seats * priceperC_Seat ;
Write this program, using only one class, and the main function of the program.
1
Expert's answer
2020-06-30T08:02:19-0400

// the preprocessing directives

#include <iostream>

#include <iomanip>   // setprecision(2) and fixed


using namespace std;

// claas declaration

class Sales

{

 private:

  float priceperA_Seat;   

  float priceperB_Seat;

  float priceperC_Seat;

  int numberofA_Seats;   

  int numberofB_Seats;

  int numberofC_Seats;

 public:

    //default constructor

Sales () {

    numberofA_Seats = 0;   

    numberofB_Seats = 0;

    numberofC_Seats = 0;


   priceperA_Seat = 0;   

    priceperB_Seat = 0;

    priceperC_Seat = 0;

   }

   //no-default constructor

Sales (int nA, int nB, int nC, float pA, float pB, float pC) {

   numberofA_Seats = nA;   

    numberofB_Seats = nB;

    numberofC_Seats = nC;


    priceperA_Seat = pA;   

    priceperB_Seat = pB;

    priceperC_Seat = pC;


   }

float totalSales(){

   float totalSales = 0;

   totalSales = numberofA_Seats * priceperA_Seat +

   numberofB_Seats * priceperB_Seat +

   numberofC_Seats * priceperC_Seat;

   return totalSales;

}


};


int main() {

   int numberA, numberB, numberC;

   float priceA, priceB, priceC;


   cout << setprecision(2) << fixed;


   cout << "Number of tickets A sold: ";

   cin >> numberA;

   cout << "Price of a ticket A: ";

   cin >> priceA;   


   cout << endl <<"Number of tickets B sold: ";

   cin >> numberB;   

   cout << "Price of a ticket B: ";

   cin >> priceB;   


   cout << endl << "Number of tickets C sold: ";

   cin >> numberC;   

   cout << "Price of a ticket C: ";

   cin >> priceC;


   // Declare a Sales class object      

   Sales s01(numberA, numberB, numberC, priceA, priceB, priceC );


   cout << endl <<"The total ticket sales of a concert: $"<<s01.totalSales();


   return 0;

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS