Question

Wadow Help COS1511 2012 2. COS1511 Nov 2012 semester 1 past pap... 2012_2017-sem2... COS1511 201 3 2 Solutions to exeras.. CO

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

CalculateSalary.cpp:

#include <iostream>
using namespace std;
int main()
{
        const float SUNDAY = 200;
        float other = 100;
        char whichDay;
        float totalAmount = 0;
        int nrSundays = 0;
        cout << "Enter first day: '2' for sunday, '1' for other days" << endl;
        cin >> whichDay;
        while (whichDay != 'x')
        {
                //if 1 is entered add 100 to total salary
                if (whichDay == '1')
                        totalAmount += other;
                //if 2 is entered add 200 to total salary and increment number of sundays
                else if (whichDay == '2')
                {
                        totalAmount += SUNDAY;
                        nrSundays++;
                }
                else
                {
                        cout << "Invalid entry....." << endl;
                }
                cout << "Enter first day: '2' for sunday, '1' for other days" << endl;
                cin >> whichDay;
        }
        cout << "Total Salary: " << totalAmount << endl;
        cout << "number of sundays worked: " << nrSundays << endl;
        return 0;

}

Output:

Add a comment
Know the answer?
Add Answer to:
Wadow Help COS1511 2012 2. COS1511 Nov 2012 semester 1 past pap... 2012_2017-sem2... COS1511 201 3...
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
  • QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they...

    QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on a Sunday. They only work when the company contacts them, so they do not work the whole month. Complete the program below that asks the user to enter the days that the worker has worked. The character 'l' is entered if the day is Monday to Saturday and '2' if it is...

  • QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they...

    QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on a Sunday. They only work when the company contacts them, so they do not work the whole month. Complete the program below that asks the user to enter the days that the worker has worked. The character '1' is entered if the day is Monday to Saturday and '2' if it is...

  • QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they...

    QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on a Sunday. They only work when the company contacts them, so they do not work the whole month. Complete the program below that asks the user to enter the days that the worker has worked. The character 'l'is entered if the day is Monday to Saturday and 2' if it is a...

  • QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they...

    QUESTION 2 10 marks A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on a Sunday. They only work when the company contacts them, so they do not work the whole month. Complete the program below that asks the user to enter the days that the worker has worked. The character 'l' is entered if the day is Monday to Saturday and 2' if it is...

  • A construction company pays its temporary workers R100 per day if they work on a Monday...

    A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on a Sunday. They only work when the company contacts them, so they do not work the whole month. Complete the program below that asks the user to enter the days that the worker has worked. The character 'l' is entered if the day is Monday to Saturday and '2' if it is a Sunday. A total...

  • A construction company pays its temporary workers R100 per day if they work on a Monday...

    A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on a Sunday. They only work when the company contacts them, so they do not work the whole month. Complete the program below that asks the user to enter the days that the worker has worked. The character 'l' is entered if the day is Monday to Saturday and 2’ if it is a Sunday. A total...

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

  • note: expecting help for assignment 3 but posting data from assignment 2 as well because the...

    note: expecting help for assignment 3 but posting data from assignment 2 as well because the question is linked with that Question On March 1 2012 Philip inherited a property in inner Sydney at 151 Temple Street from his Aunt. The property had been used for commercial purposes but as the area was central to his job as an interior designer he decided to move in immediately and renovate to convert to residential accommodation. The property was valued by the...

  • Question 2: Critical Thinking 3-05 a Ayayai Park was organized on April 1, 2019, by Erica...

    Question 2: Critical Thinking 3-05 a Ayayai Park was organized on April 1, 2019, by Erica Hatt. Erica is a good manager but a poor accountant. From the trial baance prepared by a part-time bookkeeper, Erica prepared the following income statement for the quarter that ended March 31, 2020 Ayayaİ PARK Income Statement For the Quarter Ended March 31, 2020 Revenues Rent revenue $89,800 Operating expenses Advertising Salaries ad wages Utilities Depreciation Maintenance and repairs Total operating expenses $5,400 30,000...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

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