Answer to Question #254315 in C++ for Fisiwe Shezi

Question #254315

Parents of the pupils of the Park Primary School must pay an amount for outfits for the annual

play. All pupils take part in the play, except the Grade 0 pupils. The amount that the parents have

to pay is calculated as follows:

 The cost of the outfits for Grade 1 and 2 pupils is R45.

 The cost of the outfits for Grades 3 to 5 is R65.

 Grade 6 and 7 pupils may play one or two roles. If they play a lead role, they may only play

one role. The cost of the outfits is R70 if they play one role. If this role is a lead role, the

cost is R100. If they play two roles, the cost is R130

Use a switch statement and write down ONLY the necessary C++ statements to

calculate and display the amount to be paid or display an appropriate error message if

required.

Do NOT write a complete program. Use the following

variables:

int grade;

int fee;

bool leadrole; //true if a child plays a lead role

bool roles2; //true if a child plays 2 roles


1
Expert's answer
2021-10-25T17:56:11-0400
#include <iostream>


using namespace std;


int main()
{
	cout<<"Enter the grade\n";
	
int grade;
cin>>grade;
int fee;
bool leadrole;
bool roles2;
switch(grade){
case 1: fee=45;break;
case 2: fee=45;break;
case 3 ... 5:
 fee=65;break;
case 6 ... 7:
cout<<"Enter roles\n: ";
cin>>roles2;
if(!roles2){
if(leadrole){
fee=100;
}
else{
fee=70;
}
}
else{
fee=130;
}
break;


default: cout<<"Invalid grade";
}
  


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