Question: In this exercise, write a complete Java program that reads integer numbers from the user until a negative value is entered. It should then

In this exercise, write a complete Java program that reads integer numbers

 from the user until a negative value is entered. It should then 

In this exercise, write a complete Java program that reads integer numbers from the user until a negative value is entered. It should then output the average of the numbers, not including the negative number. If no non-negative values are entered, the program should issue an error message. You are required to use a do-while loop to solve this problem. Solutions that do not use a do-while loop will be given a zero. Make sure to add appropriate comments to your code. Two samples of how your program should run are shown below (user input is in bold): Please enter some numbers (a negative to stop): 7 3 5 2 -1 Average: 4.25 Please enter some numbers (a negative to stop): -2 Activate Window Go to Settings to activ Write a complete Java program that reads a number from the user. This number represents the initial balance of a bank account. Your program should then determine how many years and months it takes for the bank account to become depleted, given the following conditions: a. Interest is calculated and added to the account at the beginning of every month at 0.5% b. At the end of every month $500 is withdrawn from the account to pay for rent Note: the account is depleted when there is no longer enough money in the account to make the $500 withdrawal. Make sure to neatly display the number of years and months it takes the account to deplete, and if the time it takes is less than one year, only display the number of months. Furthermore, if the number of years or months is 1, make sure to display the words year or month instead of years or months. Three sample outputs of your program are shown below (user input is in bold): Enter balance:9400 1 year and 8 months Enter balance: 500 2 months Enter balance: 12000

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 Programming Questions!