Question

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

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 leadrole, they may only play one role.
The cost of the outfits  is R70 if they play one role. If this role is a leadrole, the cost is R100. If they play two
roles, the cost is R130
Use a switchstatement 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 leadrole
bool roles2; // true if a child plays 2 roles
Assume that values have been assigned to these variables already.

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

Here is the solution to above problem in C++. PLEASE GIVE A THUMBS UP!!!

Read the code comments for more information

C++ CODE

#include<iostream>
using namespace std;


int main()
{
   int grade=6;
   int fee;
   bool leadrole=true;
   bool roles2=false;
  
   switch(grade)
   {
       //grade 1 and 2
       case 1 : fee=45;
               break;
       case 2: fee=45;
               break;
       //grade 3 to 5
       case 3: fee=65;
               break;
       case 4: fee=65;
               break;
          
       case 5: fee=65;
               break;
       //grade 6 and 7
       case 6:
       {
               //if two roles
           if(roles2==true&&leadrole==false)
               fee=130;
           //if lead role
           else if(roles2==false && leadrole==true)
               fee=100;
           //if one role only
           else if(roles2==false)
               fee=70;
      
       }
       break;
      
           case 7:
       {
               //if two roles
           if(roles2==true&&leadrole==false)
               fee=130;
           //if lead role
           else if(roles2==false && leadrole==true)
               fee=100;
           //if one role only
           else if(roles2==false)
               fee=70;
       }
       break;
       //erro message
       default : cout<<"NOT A VALID GRADE\n";
      
   }
   //total fee
   cout<<"FEE IS: "<<fee<<endl;
   return 0;
}

SCREENSHOT OF OUTPUT

FEE IS: 100 Process exited after 1.524 seconds with return value o Press any key to continue .

Add a comment
Know the answer?
Add Answer to:
Parents of the pupils of the Park Primary School must pay an amount for outfits for...
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
  • Parents of the pupils of the Park Primary School must pay an amount for outfits for...

    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...

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

    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 O 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...

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

    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...

  • QUESTION 1 12 marks Parents of the pupils of the Park Primary School must pay an...

    QUESTION 1 12 marks 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 O 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...

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

    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...

  • QUESTION 2 [12] Parents of the pupils of the Park Primary School must pay an amount...

    QUESTION 2 [12] 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...

  • SECTION B 80 MARKS QUESTION 1 12 marks Parents of the pupils of the Park Primary...

    SECTION B 80 MARKS QUESTION 1 12 marks 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 O 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...

  • SECTION B 80 MARKS QUESTION 1 12 marks Parents of the pupils of the Park Primary...

    SECTION B 80 MARKS QUESTION 1 12 marks 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...

  • SECTION B 80 MARKS QUESTION 1 12 marks Parents of the pupils of the Park Primary...

    SECTION B 80 MARKS QUESTION 1 12 marks 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...

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