Design a program in pseudocode that calculates the amount of money a person would earn over a period of time if their salary is one penny the first day, and then doubles each day. The program should ask the user for the number of days. Display what the salary was for each day, and then show the total pay for the end of the period. The output should be displayed in dollar amount, not number of pennies.

I have the code but i do not know if it works PLEASE HELP!!!!!:

Declare Integer days, counter = 1, penny = 1, total = 0

Declare Real salary, totalPay

Display "Enter a number of days."

Input days

Display "Days",TAB,"Salary"

While counter<= days

Set salary = penny/100

Set total = penny

Display counter, TAB, salary

Set penny = penny * 2
Set counter = counter + 1

End While
Set totalPay = total * 100

Display "The total payment of your time working here will be $", totalPay

I am not sure abut the rest, but how you have it set up to display pennies as a dollar amount isn't going to work. For an example, if you end up with 100 pennies at the end, and you multiply that by 100, you will get 10,000, not $1.00. It would be easier if you set penny=.01 (not sure what variable type it would be, it's been a while) and not even mess with changing it into a dollar amount. Just display totalPay as the final amount of penny. The decimal will take care of the conversion itself.

I see that the line that says


Set total = penny

should have the penny value dividing by 100 like the line

Set salary = penny/100

I see that error but other than that is there anything else wrong like a variable placement or variable value wrong?

The pseudocode you have provided looks correct and should work as intended. However, there are a few improvements that could be made for readability and accuracy. Here is an updated version of the pseudocode:

Declare Integer days, counter = 1
Declare Real penny = 0.01, totalPay = 0.0

Display "Enter the number of days: "
Input days

Display "Day", TAB, "Salary"
While counter <= days
Set totalPay = totalPay + penny
Display counter, TAB, penny

Set penny = penny * 2
Set counter = counter + 1

End While

Display "Total pay at the end of", days, "days is: $" + totalPay

Your pseudocode is mostly correct, but there are a few adjustments that can be made to ensure accurate calculations and proper formatting of the output.

Here's an updated version of the pseudocode:

1. Declare variables: days, counter = 1, penny = 1, total = 0, totalPay

2. Display "Enter the number of days."

3. Input days

4. Display "Day", TAB, "Salary"

5. While counter <= days

- Set salary = penny / 100
- Set total = total + penny
- Display counter, TAB, salary
- Set penny = penny * 2
- Set counter = counter + 1

6. Set totalPay = total / 100.0 (Divide by 100.0 to convert total pennies to dollars)

7. Display "The total payment for the period is $", totalPay

In addition to these changes, I replaced the line "Set totalPay = total * 100" with "Set totalPay = total / 100.0" since the total was already accumulated in pennies in the "total" variable. Dividing by 100.0 will convert the result from cents to dollars.

Remember to convert this pseudocode into the syntax of the programming language you are using, such as Python, Java, or C++.