Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a Java program that implements the described functionali... blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intermediate Microeconomics and Its Application

Authors: walter nicholson, christopher snyder

11th edition

9781111784300, 324599102, 1111784302, 978-0324599107

More Books

Students also viewed these Programming questions

Question

-4 1 9. Let A = Find A-1, (A") and verify that (A")= (A-1)".

Answered: 1 week ago

Question

2. Show that (a) if and , then (b) (c)

Answered: 1 week ago

Question

*4. Write the structure function corresponding to the following:

Answered: 1 week ago

Question

5. Find the minimal path and minimal cut sets for:

Answered: 1 week ago