In this exercise, write a complete Java program that reads integer numbers from the user until...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Let r and s be solutions to the quadratic equation x 2 b x + c = 0. For n N, define d0 = 0 d1 = r s dn = b dn1 c dn2 (n 2) Prove that dn = r n s n for all n N. [4 marks] (b) Recall that a commutative...
-
: (i) What data structures are maintained by the page manager. (ii) What happens when a machine performs a read operation to a page. (iii) What happens when a machine performs a write operation to a...
-
Consider an atom diffuses in a 3 D simple cubic lattice by a random walk mechanism. The atom jumps 6 x 1 0 - 5 times per second at 3 0 0 K and 3 x 1 0 4 times per second at 6 0 0 K . Assuming that...
-
Cow Chips, Inc., a large fertilizer distributor based in California, is planning to use a lockbox system to speed up collections from its customers located on the East Coast. A Philadelphia-area bank...
-
Resistors labeled as 100 are purchased from two different vendors. The specification for this type of resistor is that its actual resistance be within 5% of its labeled resistance. In a sample of...
-
An effective way to learn how companies respond to the competing pressures to be globally integrated and locally responsive is to study them in action. Referring back to Exhibit 6.3, search online...
-
Recognition of Profit, Percentage-of-Completion In 2010 Gurney Construction Company agreed to construct an apartment building at a price of $1,200,000. The information relating to the costs and...
-
1. [10] Is Grtzsch graph M(C5) Hamiltonian? Is the complement of M(C5) Hamilto- nian? Justify your answer.
-
A trader just entered a short position in two December 2023 $/CHF futures contracts when the futures price was $1.1338/CHF. CHF is the symbol of the Swiss franc. Each contract is on CHF 125,000. The...
-
what accounts are involved when you buy assets on credit? Is it a debit or a credit to each account?
-
Western Co , is leasing its entire 1 5 - story property to medical businesses. Dandy Dentist ( DD ) ( tenant ) has rented a total net rentable area ( NRA ) of 1 4 0 2 0 square feet on the 3 rd floor....
-
Individual A has taxable income of $42,132 in 2022. Individual A is single and lives in a house with Individual B. Individual B is Individual A's 14-year old daughter and Individual B has net income...
-
A new three-year CMO has two tranches. The 'A' tranche has a principal of $39.1 million with an annual coupon of 3.97%. The 'Z' tranche has a coupon of 5.93% with a principal of $45.5 million. The...
-
A new three-year CMO has two tranches. The 'A' tranche has a principal of $28.9 million with an annual.coupon of 3.25%. The 'Z' tranche has a coupon of 5.21% with a principal of $34.7 million. The...
-
Metlock, Inc., spent $48,600 in attorney fees while developing the trade name of its new product, the Mean Bean Machine. Prepare the journal entries to record the $48,600 expenditure and the first...
-
Burberrys competitive advantage is through its differentiation strategy. What risk should Burberry remain aware of?
-
Using the code shown below, what will be displayed when the input is as follows: (a) -1 (b) 0 (c) 1 Input Number If Number < 0 Then Write "1" Else If Number == 0 Then Write "2" Else Write "3" End If...
-
What is the output of code corresponding to the following pseudocode? Suppose that the file "data" consists of the following records: "Huey",1,2 "Dewey",4,5 "Louie",7,8 Declare Ducks[10] As String...
-
Help users calculate their cars miles per gallon. Write a program to allow a user to enter the number of miles driven and the number of gallons of gas used. The output should be the miles per gallon....
-
Explain the FAIR approach to ethical business communications.
-
Watch at least three videos of interviews with executives talking about corporate values. In four to five paragraphs, summarize what you learned. Consider the following options for gathering...
-
As a former chair of the U.S. Federal Reserve once said, Rules cannot take the place of character. In two to three paragraphs, explain what you think he meant by this statement.
Study smarter with the SolutionInn App