4G 18% L MTN SA 39B/s 22:59 T29 144 100 1000 14 Submit: question4.cpp + output...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4G 18% L MTN SA 39B/s 22:59 T29 144 100 1000 14 Submit: question4.cpp + output (15 marks) QUESTION 5: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS (10 marks) QUESTION 5a Write a program named question5a.cpp that will calculate and print pay slips. User inputs are the name of the employee, the number of hours worked and the hourly pay rate. You have to declare three functions. a) one for input b) one to calculate the employee's pay; and c) one to print the payslip. The input function has to input the name of the employee, the number of hours worked and the hourly pay rate into the variables theEmployee, theHoursWorked and the PayRate. The variable employee is a string and the other two variables are of type float. As the values of theEmployee, theHoursWorked and the PayRate will be changed in this function, reference parameters need to be used 7 cos1511/103/2/2019 The calculation function will receive two parameters that represent the number of hours worked and the hourly pay rate, do the calculation and return the pay for the employee. An employee, who has worked more than 40 hours, is paid 1.5 times the hourly pay rate for each hour of overtime. As the parameters are not changed in the function, they should be value parameters. The function should return a float value which represents the pay. The output function has to display the name of the employee, the number of hours worked, the number of overtime hours and the hourly pay rate entered by the user as well as the employee's pay. For example: Pay slip for Harry Matsipe Hours worked: 43.5 hours Overtime hours: 3.5 Hourly pay rate: R125.35 Pay: R5672.09 The main function includes a for loop that allows the user to repeat the calculation of a pay slip for five employees We give the main function below. You must submit the three functions you have developed as well as output for repeating the loop five times with the following input data: Harry Matsipe 43.5 125.35 Ellen Malan 39.4 112.75 Joey Rashdien 40 120.45 Mpho Bopape 41.2 123.60 Veli Singh 39.7 135.30 QUESTION 5b NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. If pensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20% (12 marks) discount. Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for just a movie ticket alone. Write a program named question5b.cpp that will consist of two functions. The program must prompt the user for type of customer ('p' for pensioner, 's' for student, 'o' for other). It must then call the relevant function according to that entry. The first function must receive the customer type and calculates discount for pensioners and students. The second function calculates the discount for customers that are not pensioners or students. (13 marks) QUESTION 5c Write a program named question6c.cpp that demonstrates the use of the following functions. A C++ function named getName () prompts the user for two string values; first name and last name and return a combination of the two as one value. The second function getHours () calculate employee's weekly pay, it must receive one argument, ful1 Name, a string variable and a float value for the rate. It must then prompt the user for hours worked for each day of the week, i.e. Monday Friday and calculates the weekly pay. Employees who have worked more than 40 hours that week will receive a bonus of 10% and those who have worked less than 40 hour will receive 10% less pay for that week. Submit: Program question5a.cpp+ output Program question5b.cpp+ output 4G 18% L MTN SA 39B/s 22:59 T29 144 100 1000 14 Submit: question4.cpp + output (15 marks) QUESTION 5: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS (10 marks) QUESTION 5a Write a program named question5a.cpp that will calculate and print pay slips. User inputs are the name of the employee, the number of hours worked and the hourly pay rate. You have to declare three functions. a) one for input b) one to calculate the employee's pay; and c) one to print the payslip. The input function has to input the name of the employee, the number of hours worked and the hourly pay rate into the variables theEmployee, theHoursWorked and the PayRate. The variable employee is a string and the other two variables are of type float. As the values of theEmployee, theHoursWorked and the PayRate will be changed in this function, reference parameters need to be used 7 cos1511/103/2/2019 The calculation function will receive two parameters that represent the number of hours worked and the hourly pay rate, do the calculation and return the pay for the employee. An employee, who has worked more than 40 hours, is paid 1.5 times the hourly pay rate for each hour of overtime. As the parameters are not changed in the function, they should be value parameters. The function should return a float value which represents the pay. The output function has to display the name of the employee, the number of hours worked, the number of overtime hours and the hourly pay rate entered by the user as well as the employee's pay. For example: Pay slip for Harry Matsipe Hours worked: 43.5 hours Overtime hours: 3.5 Hourly pay rate: R125.35 Pay: R5672.09 The main function includes a for loop that allows the user to repeat the calculation of a pay slip for five employees We give the main function below. You must submit the three functions you have developed as well as output for repeating the loop five times with the following input data: Harry Matsipe 43.5 125.35 Ellen Malan 39.4 112.75 Joey Rashdien 40 120.45 Mpho Bopape 41.2 123.60 Veli Singh 39.7 135.30 QUESTION 5b NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. If pensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20% (12 marks) discount. Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for just a movie ticket alone. Write a program named question5b.cpp that will consist of two functions. The program must prompt the user for type of customer ('p' for pensioner, 's' for student, 'o' for other). It must then call the relevant function according to that entry. The first function must receive the customer type and calculates discount for pensioners and students. The second function calculates the discount for customers that are not pensioners or students. (13 marks) QUESTION 5c Write a program named question6c.cpp that demonstrates the use of the following functions. A C++ function named getName () prompts the user for two string values; first name and last name and return a combination of the two as one value. The second function getHours () calculate employee's weekly pay, it must receive one argument, ful1 Name, a string variable and a float value for the rate. It must then prompt the user for hours worked for each day of the week, i.e. Monday Friday and calculates the weekly pay. Employees who have worked more than 40 hours that week will receive a bonus of 10% and those who have worked less than 40 hour will receive 10% less pay for that week. Submit: Program question5a.cpp+ output Program question5b.cpp+ output
Expert Answer:
Answer rating: 100% (QA)
Program include using namespace std struct employee string name float ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in alphabetical order, and displays the sorted words separated by spaces....
-
Write a program named TemperaturesComparison that allows a user to input five daily Fahrenheit temperatures that must range from ?30 to 130; if a temperature is out of range, require the user to...
-
Write a program named ReadList.java that reads the file integers.dat. If the file does not exist, it should exit gracefully (i.e.withoutcrashing)and provide an appropriate error message.If the file...
-
The word culture is used in many ways, such as when people talk about national culture, organisational culture, political culture or youth culture. In which ways do the meanings of culture differ?
-
Random samples of n = 20 circuit breakers are tested for damage caused by shipment in each lot of 4,000 received. Lots with more than one defective are pulled and subjected to 100 percent inspection....
-
Name and describe the two key components of a balance of trade.
-
Consider the net cash flows and salvage values shown below. Assume the alternatives can be indefinitely renewed with the same cash flows and salvage values. Using a MARR of 8%, specify the planning...
-
This problem is based on the 2008 annual report of Intel Corporation in the appendix. Find in the Selected Financial Data (also known as the Five-Year Financial Summary), or calculate, the following...
-
Let us consider a two-link mechanism shown in figure below. Assume that 91=0 and 92 = 45; a = a = 1; -(x,y) a. Determine the Jacobian matrix for this configuration. b. Calculate the Yoshikawa's...
-
The income statement of Fezzik's Shoe Repair is as follows: On April 1, the Owner's Capital account had a balance of $12,900. During April, Fezzik withdrew $3,000 cash for personal use. Prepare...
-
An investor buys a semi-annual 9.5% coupon paying bond with a par value of R8 000 000. The yield to maturity (YTM) and clean price on 10 March 2021, when the bond is traded, are 10.5% and R87.10253%,...
-
Why do channels using marketing intermediaries for distribution?
-
Distinguish the differences between Intensive distribution, Selective distribution and Exclusive distribution with examples.
-
How can leaders cultivate a culture of trust, respect, and inclusivity to nurture fruitful collaboration among team members?
-
How does a supply chain leader become a risk management leader with integrity? Why is integrity so improve in risk management?
-
Calculate how much Mike and Vanessa will each get using property division under Ontario law. Mike and Vanessa separated June 15, 2021. Vanessa has come to you for assistance in determining how their...
-
1. Give a summary of the pre-installation tasks that you need to perform before installing Oracle Database 12c on Red Hat Enterprise. 2. What is the OFA? Explain how you would use OFA to set up...
-
If a force of F = 50 Ib is applied to the pads at A and C, determine the smallest dimension d required for equilibrium if the spring has an unstretched length of 1 ft. B 1 ft 1 ft F k = 15016/fr 1ft...
-
The planet Mercury travels in an elliptical orbit with eccentricity 0.206. Its minimum distance from the sum is 4.6 ( 107 km. Find the maximum distance from the sun?
-
Graph the curve and visually estimate its length. Then use your calculator to find the length correct to four decimal places. y = x2 + x3, 1 x 2
-
In Example 1 in Section 3.8 we modeled the world population in the second half of the 20th century by the equation P(t) = 2560e0.017185t. Use this equation to estimate the average world population...
-
What might be problematic about these responses to interview questions? How might the answers be improved? a. Q: Tell me about yourself. A: Im really easy-going and casual. b. Q: I noticed that you...
-
Revise the follow-up message below to be more professional and effective, based on the principles in this chapter. December 2, 2021 Ms. Charlotte LeClaire Pebble Creek Publishing Inc. New York, NY...
-
Write a follow-up email message or letter after an office visit or plant trip. Thank your hosts for their hospitality; relate your strong points to things you learned about the company during the...
Study smarter with the SolutionInn App