subject

Fix the code in oops2.java so that it is better structured and avoids redundancy. there are some lines of code that are repeated. think about where you can move the repeated lines in the code so that they only appear once. you do not need to add any error checking on the user input, assume that the user will always enter 1 or 2. here is the code: import java. util. scanner; public class oops2 {public static void main(string[] args) { int sum = 0; int count = 0; int total = 0; scanner console = new scanner(system. in); system. out. print("is your money multiplied 1 or 2 times? "); int times = console. nextint(); if (times == 1){ system. out. print("and how much are you contributing? "); int donation = console. nextint(); sum = sum + donation; count++; total = total + sum; } if (times == 2){ system. out. println("and how much are you contributing? "); int donation = console. nextint(); sum = sum + 2 * donation; count++; total = total + sum; } system. out. println("the total is " + total); }}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:10
What a backup plan that you have created in a event you encounter a situation
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
question
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
These statements describe lists in presentation programs: a. bullets can be turned off and on. b. bullets cannot be turned off. c. bullet styles, colors, and sizes can be changed. d. lists don't have to use bullets or numbers. e. numbering styles, colors, and sizes can be changed. f. numbers can be turned off and on. g. numbers cannot be turned off. select all that apply
Answers: 2
You know the right answer?
Fix the code in oops2.java so that it is better structured and avoids redundancy. there are some lin...
Questions
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Geography, 18.09.2020 22:01
question
Health, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Geography, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
English, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01
question
Mathematics, 18.09.2020 22:01