Question
Your job will be to write a modular program that calculates how much a person earns in a month if the salary is one penny
Your job will be to write a modular program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month, validate that it is between 1 and 31, and then display a table showing how much the salary was for each day worked, as well as the total pay earned for the month. The output should be displayed in dollars with two decimal points, not in pennies. A sample program output should look like below.
The program must have the following functions:
getDaysWorked function: will be a value returning function and should ask the user for the number of days the employee worked during the month and then return it to the caller. The function must also validate the input that the days entered is between 1 and 31 (hint: write a loop and ask the user to enter a day until it is a valid number). The main function should call this function once.
displayPays function: will be a void and should calculate how much the salary was for each day worked and display a two column table, one column is the day and second column is the pay for that day. The total pay for the month must also be displayed. The output should be nicely formatted and displayed in dollars with two decimal points, not in pennies.This function should be called just once by main function. Main function should pass the days worked to this function as an argument.
Need help asap. Thank you
How many days did the employee work this month? 4 Day 1 3 Pay 0.01 0.02 0.04 0.08 4 Total 0.15Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started