Question

A construction company pays its temporary workers R100 per day if they work on a Monday to Saturday and R200 if they work on

#include <iostream> using namespace std; int main() { const float SUNDAY = 200; float OTHER = 100; char whichDay; days float

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

code:

#include <iostream>
using namespace std;
int main()
{
const float SUNDAY=200; //salary per day for sun days
float OTHER =100; //salary for other days
char WhichDay; // day to find whether its sunday or other day
int days=0; //count otherdays
float totalAmount; //to calculate totalamount
int nrSundays=0; //to count sundays
cout<<"Enter first day:'2' for sundays:'1' for other days:'x' to termintae >>" << endl;
do //to run a loop till user enters x
{
cin >> WhichDay; //taking user input
if(WhichDay == '2') //checking whether user ipput is 2 or not
{
nrSundays++; //inrement sundays count
}
else if(WhichDay =='1') //checking whether user ipput is 1 or not
{
days++; //inrement sundays count
}
else if(WhichDay =='x') //checking whether user ipput is x or not
{
break; //break from the loop
}
else //checking invalid user input
{
cout << "Enter valid char >>>";
}
} while(WhichDay !='x');
totalAmount= (SUNDAY * nrSundays) + (OTHER * days); //calculating total amount
cout << "Total salary:" << totalAmount <<endl; //printing output
cout << "Number of sundays worked :" << nrSundays <<endl;
return 0;
}

3 8 { 1 #include <iostream> 2 using namespace std; int main() 4-{ 5 const float SUNDAY=200; //salary per day for sun days 6 f32 33 34 35 36 } totalAmount= (SUNDAY * nrSundays) + (OTHER * days); // calculating total amount cout << Total salary: << t

output:

Enter first day:2 for sundays:l for other days: x to termintae >> 1 2 3 Enter valid char >>>1 2 1 N 2 1 Total salary: 1

Add a comment
Know the answer?
Add Answer to:
A construction company pays its temporary workers R100 per day if they work on a Monday...
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 '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...

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

  • Wadow Help COS1511 2012 2. COS1511 Nov 2012 semester 1 past pap... 2012_2017-sem2... COS1511 201 3...

    Wadow Help COS1511 2012 2. COS1511 Nov 2012 semester 1 past pap... 2012_2017-sem2... COS1511 201 3 2 Solutions to exeras.. COS1511.PDF 9 / 12 100% 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...

  • Write a C++ Program. You have a following class as a header file (dayType.h) and main()....

    Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public:     static string weekDays[7];     void print() const;     string nextDay() const;     string prevDay() const;     void addDay(int nDays);     void setDay(string d);     string getDay() const;     dayType();     dayType(string d); private:     string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...

  • FILL IN THE BLANKS #include #include <> *BLANK* using namespace std; int main() {     const...

    FILL IN THE BLANKS #include #include <> *BLANK* using namespace std; int main() {     const double HOURLY_RATE = 15;     string input_str;     cout << "Enter days of attendance: " << endl;    *BLANK* (cin, input_str);     stringstream input_stream();     int total_hours = 0;     while(!input_stream.())*BLANK*     {         int hours;         string day;         input_stream >> day;         if(day ==  *BLANK*|| day == *BLANK*)         {             hours = 5;         }         *BLANK*(day == "Tuesday" || day == "Thursday")         {             hours = 4;         }         else if(day ==...

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

  • // Write a program that determines how many of each type of vowel are in an...

    // Write a program that determines how many of each type of vowel are in an entered string of 50 characters or less. // The program should prompt the user for a string. // The program should then sequence through the string character by character (till it gets to the NULL character) and count how many of each type of vowel are in the string. // Vowels: a, e, i, o, u. // Output the entered string, how many of...

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