*************************

Write a program 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 a dollar amount, not the number of pennies.

Input Validation: Do not accept a number less than 1 for the number of days worked.

Input and output should be done with Dialog and Message boxes. Your program should be well documented internally and externally

*************************

My question is where we have to display a table. How can I output a table with all of the days, pennies earned, and total on one output dialog? Is this possible?

Thanks in advance.

import javax.swing.JOptionPane; public class PenniesForPay { public static void main(String[] args) { String inputString; int pennies; // Penny accumulator int totalPay; // Total pay accumulator int maxDays; // Max number of days int day; // Day counter inputString = JOptionPane.showInputDialog("For how many days will you work? "); maxDays = Integer.parseInt(inputString); // Validate the input while (maxDays < 1){ inputString = JOptionPane.showInputDialog("The number of days " + "must be at least 1.\nEnter the number of days: "); maxDays = Integer.parseInt(inputString); } day = 1; pennies = 1; totalPay = 0; while (day <= maxDays) { // Display the day number and pennies earned. JOptionPane.showMessageDialog(null, "Day:\t" + day + "\nPennies Earned:\t" + pennies); // Accumulate the total pay. totalPay = totalPay + pennies; // Increment for the next day. day++; // Double the number of pennies. pennies = pennies * 2; } JOptionPane.showMessageDialog(null, "Total pay: $" + totalPay / 100.0); } }