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 10:00
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Communication is the exchange of information. true false
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
question
Computers and Technology, 25.06.2019 06:30
How are slides deleted from a presentation?
Answers: 1
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
Questions on the website: 13722361