Question: Java Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny

Java

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 program will prompt for input of the number of days for the period to cover.

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

Write another program that prompts the user to enter a positive nonzero integer value.

The program should use a loop to get the sum of all the odd integers from 1 up to and including the number entered.

For example, if the user enters 5, the loop will find the sum: 1 + 3 + 5 = 9

Example of what running program might look like: Enter a positive nonzero integer value: 7 The sum of the integer values from 1 to 7 = 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!