5. a. Write a class definition for an Order class for a nightclub that contains
ID: 3741133 • Letter: 5
Question
5. a. Write a class definition for an Order class for a nightclub that contains a table number, a server’s name, and the number of patrons at the table. Include a private static data member for the table minimum charge, which is $4.75. Write a main()function that declares no Order objects, but that uses a static member function to display the table minimum charge. Save the file as Order.cpp
b. Using the same Order class, write a main()function that declares an Order object, assigns appropriate values, and displays the Order data, including the minimum charge for the table (the minimum charge times the number of patrons at the table). Save the file as Order2.cpp.
Any coding assignments will have to be submitted in .cpp format and a Word document with the code copy/pasted and screenshots of the output.
Explanation / Answer
5. (a)
Source code
#include <iostream>
using namespace std;
class order
{
private:
int tablenumber, number_of_patrons;
string servername;
static double minimum_charge;
public:
void get_tablenumber(int);
void get_number_of_patrons(int);
void get_servername(string);
int display_tablenumber();
string display_servername();
int display_number_of_patrons();
static void display_minimumcharge();
double return_minimumcharge();
};
double order::minimum_charge = 4.75;
void order::get_tablenumber(int number)
{
tablenumber = number;
}
void order::get_number_of_patrons(int patron_number)
{
number_of_patrons = patron_number;
}
void order::get_servername(string name)
{
servername = name;
}
int order::display_tablenumber()
{
return tablenumber;
}
string order::display_servername()
{
return servername;
}
int order::display_number_of_patrons()
{
return number_of_patrons;
}
double order::return_minimumcharge()
{
return minimum_charge;
}
void order::display_minimumcharge()
{
cout<<" Minimum charge = " <<minimum_charge;
}
int main()
{
order::display_minimumcharge();
return 0;
}
OUTPUT
Minimum charge = 4.75
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.