// 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;
}
Comments
Leave a comment