Question

25. In this exercise, you create a program for the sales manager at Computer Haven, a small business that offers motivational

1 0
Add a comment Improve this question Transcribed image text
Answer #1

Part a and b cannot be answered due to lack of information (Figure 7-42 is not provided). I am only answering parts c, d and e.

Algorithm

Step 1: Input number of participants for each company.

Step 2: Calculate the cost for the participants of a particular company and add to the total cost. Add the number of participants of each company to the total number of registrants. Calculate the average cost per participant.

Step 3: Repeat steps 1 and 2 for as many companies as required.

Step 4: Display the total number of participants, total charge for the registrants and the average charge per participant.

C++ Code

#include<iostream>
using namespace std;

class ComputerHaven
{
   int people; //holds the total number of registrants
   double total_cost; //holds the total cost
   double avg_cost; //holds the average cost per person
   public:
       ComputerHaven() //default constructor
       {
           people=0;
           total_cost=0.0;
           avg_cost=0.0;
       }
       void getData();
       void calculate(int p);
       void display();
};

void ComputerHaven::getData() //inputs data
{
   int choice=1, participants, i=1; //variables to hold the choice, participant for each company and a count for the company being entered
   while(choice==1) //loop to enter the number of registrants for as many companies as needed
   {
       cout<<"Company "<<i;
       cout<<"\nEnter number of participants: ";
       cin>>participants;
       if(participants>0)
       {
           calculate(participants); //cost is calculated only for valid number of participants
           i++; //company number increased only if valid number of participants is entered
       }
       else
           cout<<"Number of participants must be greater than or equal to 1.\n";
       cout<<"Press 1 to enter registrants for more companies, press 0 to stop: ";
       cin>>choice;
   }
}

void ComputerHaven::calculate(int p) //calculates number of participants, total cost and average cost
{
   people+=p;
   if(p>=1 && p<=3)
       total_cost+=(p*150);
   else if(p>=4 && p<=9)
       total_cost+=(p*100);
   else
       total_cost+=(p*90);
   avg_cost=total_cost/people;
}

void ComputerHaven::display() //displays the number of participants, total cost and average cost
{
   cout<<"Total number of people registered: "<<people;
   cout<<"\nTotal charge is: $"<<total_cost;
   cout<<"\nAverage charge per registrant is: $"<<avg_cost;
}

int main() //main function
{
   ComputerHaven obj;
   obj.getData();
   obj.display();
}

Sample Inputs and outputs

1. 4 participants, 2 participants:

Total number of people registered: 6
Total charge is: $700
Average charge per registrant is: $116.67

2. 8 participants, 0 participants, 2 participants, 14 participants

Total number of people registered: 24
Total charge is: $2360
Average charge per registrant is: $98.3333

Add a comment
Know the answer?
Add Answer to:
25. In this exercise, you create a program for the sales manager at Computer Haven, a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Mountain Coffee wants a program that allows a clerk to enter the number of pounds of...

    Mountain Coffee wants a program that allows a clerk to enter the number of pounds of coffee ordered, the price per pound, and whether the customer should be charged a 3.5% sales tax. The program should calculate and display the total amount the customer owes. Use an int variable for the number of pounds, a double variable for the price per pound, and a char variable for the sales tax information. a. Create an IPO chart for the problem, and...

  • chapter 7. Create a program that allows the user to enter the ages (in years) of...

    chapter 7. Create a program that allows the user to enter the ages (in years) of five people. The program should display the average age. Use the for the statement. Display the average age with one decimal place. If necessary, create a new project named TryThis15 Project, and save it in the Cpp8\Chap07 folder. Enter the C++ instructions into a source file named TryThis15.cpp. Also, enter appropriate comments and any additional instructions required by the compiler. Test the program using...

  • How do you solve this assignment? Create a program that displays the ending balance in a...

    How do you solve this assignment? Create a program that displays the ending balance in a savings account, given the beginning balance, the deposit amounts, and the withdrawal amounts. Use two loops in the program: one to get the deposit amounts, and the other to get the withdrawal amounts. a. Create an IPO chart for the problem, and then desk-check the algorithm two times, using the data shown in Figure 7-52. xid-26481329_1 b. List the input, processing, and output items,...

  • C++ The manager of Keystone Tile wants an application that displays the area of a rectangular...

    C++ The manager of Keystone Tile wants an application that displays the area of a rectangular floor, given its measurements in feet. It should also display the total cost of tiling the floor, given the price per square foot of tile. 1-Create a new project named Intermediate13 Project, and save it in the Cpp8\Chap04 folder. Enter your C++ instructions into a source file named Intermediate13.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Test the program...

  • ipo chart c++

    I CAN NOT FIGURE THIS OUTTHE ACCOUNTANT AT Typing HAVEN WANTS A PROGRAM THAT WILL HELP HER PREPARE A CUSTOMER'S BILL. SHE WILL ENTER THE NUMBER OF TYPED ENVELOPES AND THE NUMBER OF TYPED PAGES,AS WELL AS THE CHARGES PER TYPED ENVELOPE AND THE CHARGE PER TYPED PAGE. THE PROGRAM SHOULD CALCULATE AND DISPLAY THE AMOUNT DUE FOR THE ENVELOPES, THE AMOUNT DUE FORTHE PAGES, AND THE TOTAL AMOUNT DUE. Calculate AN IPO CHART FOR THIS PROBLEM. DESK CHECK THE...

  • The manager of a local restaurant wants a program that displays the total cost for running...

    The manager of a local restaurant wants a program that displays the total cost for running a party in the restaurant’s banquet room. The restaurant charges a base fee for renting the room. It also charges a fee per guest. Complete an IPO chart for this problem. Desk-check the algorithm twice, using your own sets of data. please use c++ language

  • Please add code for program. movies.txt file. LAB 14-2 Plan and Create In this lab, you...

    Please add code for program. movies.txt file. LAB 14-2 Plan and Create In this lab, you will plan and create an algorithm for Cheryl Liu, the owner of a candy shop named Sweets-4-You. The problem specification is shown in Figure 14-15. Problem specification Cheryl Liu is the owner of a candy shop named Sweets-4-You. She wants a program that displays the following menu: Menu Options 1 Add Records 2 Display Total Sales 3 Exit If Cheryl selects option 1, the...

  • Create a Java Program to calculate baggage charges. Here are the rules: A. Two bags per...

    Create a Java Program to calculate baggage charges. Here are the rules: A. Two bags per person are free. B. The Excess Bag Charge is $75 per bag. The program needs to do the following: 1. In your main method(),    Create integers to store the number of Passengers and also the total number of bags    Prompt for the number of passengers on a ticket.    Prompt for the total number of bags for all passengers on a ticket....

  • Must be done in C# please! Thanks! In this assignment you will create a program named...

    Must be done in C# please! Thanks! In this assignment you will create a program named Test Scores that displays the average of all tests; average midterm score; average final score; and displays the midterm or final score of a particular student. Create a class level two dimensional integer array named Grades initialized with the following data: 897 242 301 987 116 450 865 128 992 109 88 75 94 70 90 87 81 79 97 79 78 80 92...

  • As Sales Manager for Montevideo Productions, Inc., you are planning to review the prices you charge...

    As Sales Manager for Montevideo Productions, Inc., you are planning to review the prices you charge clients for television advertisement development. You currently charge each client an hourly development fee of $2,900. With this pricing structure, the demand, measured by the number of contracts Montevideo signs per month, is 11 contracts. This is down 7 contracts from the figure last year, when your company charged only $2,200. (a) Construct a linear demand equation giving the number of contracts q as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT