I must write a program using Java that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should display a table showing the salary for each day, and then show the total pay at the end of the period. The output should be displayed in dollar amount.

I don't know how to do computer programming, but his/her salary for the 20th day would be $5,242.88.

bbb

To solve this problem, you can use a loop in Java to calculate the salary for each day and keep track of the total pay. Here's an example solution:

```java
public class SalaryCalculator {
public static void main(String[] args) {
int numDays = 30; // number of days to calculate the salary for
int salaryInPennies = 1; // starting salary in pennies

// calculate the salary for each day and keep track of the total pay
int totalPayInPennies = 0;
for (int day = 1; day <= numDays; day++) {
// calculate the salary for the current day
int salaryForDay = salaryInPennies * (int) Math.pow(2, day - 1);

// add the salary for the current day to the total pay
totalPayInPennies += salaryForDay;

// display the salary for the current day
System.out.println("Day " + day + ": $" + salaryForDay / 100.0);
}

// display the total pay
System.out.println("Total pay: $" + totalPayInPennies / 100.0);
}
}
```

In this program, we first define the number of days to calculate the salary for (in this case, 30 days) and the starting salary (1 penny).

Next, we use a `for` loop to iterate over each day. Inside the loop, we calculate the salary for the current day by multiplying the starting salary by 2 raised to the power of the day number minus 1.

Then, we add the salary for the current day to the total pay.

After that, we display the salary for the current day by dividing it by 100 to convert it from pennies to dollars.

Finally, we display the total pay at the end of the period by dividing it by 100 to convert it from pennies to dollars.

When you run this program, it will display a table showing the salary for each day, as well as the total pay at the end of the period, all in dollar amounts.