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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:30, mjweed2456
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, opgbadwolf5
What provides an array of buttons for quick access to commonly used commands and tools
Answers: 1
image
Computers and Technology, 24.06.2019 08:30, 5theth
Intellectual property rights are exclusive rights that protect both the created and the creation. ipr offers exclusively what benefits to the person or people covered by it
Answers: 3
image
Computers and Technology, 24.06.2019 10:30, pino40
Which of the following types of software is most applicable to the promotion of new products through advertising? a. databases b. spreadsheets c. web design programs d. word processing tools
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 in other subjects: