a Java program that calculates how much a person earns in a month if the salary is
Question:
a Java 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 continue to double each day the employee works. The program keeps doing it until the user enters N from the keyboard.
The program should ask the user for the number of days the employee worked during the month and should display a table showing how much the salary was for each day worked, as well as the total pay earned for the month. Do not accept a number less than 1 or more than 31 for the number of days worked. The output should be displayed in dollars with two decimal points, not in pennies.
Hint:Use the NumberFormat class to format the total with the $ sign and the DecimalFormat to format the pay in the table to two decimal places.
Finally, ask the user "Do you want to do it again: Enter Y for yes and N for no". If the user enters N then the program terminates otherwise prompts again for the number of days.
Example output with valid input :
How many days did the employee work this month? 3
Day Pay
------------------
1 0.01
2 0.02
3 0.04
------------------
Total $0.07
Do you want to do it again: Enter Y for yes and N for no: Y
How many days did the employee work this month? 8
Day Pay
------------------
1 0.01
2 0.02
3 0.04
4 0.08
5 0.16
6 0.32
7 0.64
8 1.28
------------------
Total $ 2.55
Do you want to do it again: Enter Y for yes and N for no: N
Goodbye!
Intermediate Microeconomics and Its Application
ISBN: 978-0324599107
11th edition
Authors: walter nicholson, christopher snyder