Question

QUESTION 2 [12] Parents of the pupils of the Park Primary School must pay an amount for outfits for the annual play. All pupi

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

The program for calculating the amount to be paid by the students is given below-

The necessary C++ statements are-

int amount = 0;
    switch(grade)
    {
        case 1:
        case 2:
            amount = 45;
            break;

        case 3:
        case 4:
        case 5:
            amount = 65;
            break;
        
        case 6:
        case 7:
            if(roles2 == false)//Single role is played
            {
                if(leadrole)//If single role is leadrole
                    amount = 100;
                else
                    amount = 70;
            }
            else //For 2 roles
                amount = 130;
            break;
        
        default:
            cout << "Wrong grade is chosen.";
    }
    cout << "Amount to be paid: "  << amount;

The complete program if you want is-

#include<iostream>
#include<cstdio>
 
using namespace std;

int main()
{
    //As given in the question, these values are already present. Else input it by cin.
    int grade;
    int fee;
    bool leadrole;
    bool roles2;

    int amount = 0;
    switch(grade)
    {
        case 1:
        case 2:
            amount = 45;
            break;

        case 3:
        case 4:
        case 5:
            amount = 65;
            break;
        
        case 6:
        case 7:
            if(roles2 == false)//Single role is played
            {
                if(leadrole)//If single role is leadrole
                    amount = 100;
                else
                    amount = 70;
            }
            else //For 2 roles
                amount = 130;
            break;
        
        default:
            cout << "Wrong grade is chosen.";
    }
    cout << "Amount to be paid: "  << amount;
    return 0;
}

Code Screenshot -

File Edit Selection View Go Run Terminal Help e Q 9 La 8 m * temp.cpp X home > mohit > Desktop > G temp.cpp > main() 1 #inclu

Run the code -

  • Compile it by g++ <filename.cpp>
  • Run it as ./a,out

OUTPUT -

If I manually set the values, grade=6,leadrole=false,roles2=true, then the output will be-

(base) mohit@wildbeast:-/Desktop$ g++ temp.cpp (base) mohit@wildbeast:-/Desktop $ ./a.out Amount to be paid: 130

Add a comment
Know the answer?
Add Answer to:
QUESTION 2 [12] Parents of the pupils of the Park Primary School must pay an amount...
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...

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

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

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

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

  • 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