create a program for the sales manager at Computer Haven a s
create a program for the sales manager at Computer Haven, a
small business that offers motivational seminars to local companies. Figure 7-53 shows
the charge for attending a seminar. Notice that the charge per person depends on the
number of people the company registers. For example, the cost for four registrants
is $400; the cost for two registrants is $300. The program should allow the sales manager
to enter the number of registrants for as many companies as needed. When the sales
manager has finished entering the data, the program should calculate and display the
total number of people registered, the total charge for those registrants, and the average
charge per registrant. For example, if one company registers four people and another
company registers two people, the total number of people registered is six, the total
charge is $700, and the average charge per registrant
is $116.67.
Figure 7-53
Number of people a company registers Charge per person ($)
1 – 3 150
4 – 9 100
10 or more 90
a. Create an IPO chart for the problem, and then desk-check the algorithm appropriately.
b. List the input, processing, and output items, as well as the algorithm, in a chart similar
to the one shown earlier in Figure 7-42. Then code the algorithm into a program.
c. Desk-check the program using the same data used to desk-check the algorithm.
Display the average charge with two decimal places.
| create a program for the sales manager at Computer Haven, a small business that offers motivational seminars to local companies. Figure 7-53 shows the charge for attending a seminar. Notice that the charge per person depends on the number of people the company registers. For example, the cost for four registrants is $400; the cost for two registrants is $300. The program should allow the sales manager to enter the number of registrants for as many companies as needed. When the sales manager has finished entering the data, the program should calculate and display the total number of people registered, the total charge for those registrants, and the average charge per registrant. For example, if one company registers four people and another company registers two people, the total number of people registered is six, the total charge is $700, and the average charge per registrant is $116.67. |
Solution
IPO and Algorithm
Input
Processing
Output
No of Persons n
If the number is < 4 cost is 200
if n is between 3 and 10 then cost is 150
Else cost is 90
Multiply the number by the cost = charge
Avg = totalCharge /totalPersons
Cost of registrations
Average
Program
#include<iostream>
int main()
{
int n, totalPersons;
float charge, totalCharge;
totalCharge=0;
totalPersons=0;
while(true)
{
cout << \"Enter no of Persons or 0 to exit: \";
cin >> n;
if(n==0)
break;
else
{
if(n>=1 && n <4)
charge= n*150;
else if(n>=4 && n<10)
charge=n*100;
else charge=n*90;
}
cout << \"Total Charge for \"<<n<<\" persons is \"<<charge<<endl;
totalCharge=totalCharge+charge;
totalPersons+= n;
}
cout << \"Averahe is: \"<< totalCharge/totalPersons;
}
| Input | Processing | Output |
| No of Persons n | If the number is < 4 cost is 200 if n is between 3 and 10 then cost is 150 Else cost is 90 Multiply the number by the cost = charge Avg = totalCharge /totalPersons | Cost of registrations Average |


