Contoso Payroll Strategy Calculation Program
Calculating Contoso Payroll:
To calculate the payroll for Contoso's temporary employees based on the new strategy, which involves paying one penny on the first day, two pennies on the second day, and doubling the pennies every subsequent day, a program needs to be created.
Step-by-Step Guide:
1. Start by asking the user for the number of days they want to calculate the pay for.
2. Initialize two variables: "total_pay" to keep track of the total pay and "pennies" to store the number of pennies to be paid each day. Set the initial value of "pennies" to 1.
3. Use a for loop to iterate through each day from 1 to the user's input for the number of days.
4. Inside the loop, display the current day number and the number of pennies paid for that day.
5. Add the number of pennies paid for the current day to the total_pay variable.
6. Double the value of "pennies" for the next day by multiplying it by 2.
7. After the loop finishes, display the total pay by printing the value of the "total_pay" variable.
For example, if the user inputs 5 as the number of days, the program will output:
Day 1 pennies paid: 1
Day 2 pennies paid: 2
Day 3 pennies paid: 4
Day 4 pennies paid: 8
Day 5 pennies paid: 16
Total pay: 31
By following these steps, Contoso can accurately calculate the payroll for its temporary employees using the specified strategy.