subject

The following code is poorly structured. rewrite it so that it has a better structure and avoids redundancy. to eliminate redundancy, convert the code into a method named spending that accepts two parameters: a scanner for the console, and a string for a single person's name, and prints the appropriate information about that person's bills. your method could be called twice (once for john and once for jane) to replicate the original code's behavior.

scanner console = new scanner(system. in);
system. out. print("how much will john be spending? ");
double amount = console. nextdouble();
system. out. println();
int numbills1 = (int) (amount / 20.0);
if (numbills1 * 20.0 < amount) {
numbills1++;
}
system. out. print("how much will jane be spending? ");
amount = console. nextdouble();
system. out. println();
int numbills2 = (int) (amount / 20.0);
if (numbills2 * 20.0 < amount) {
numbills2++;
}
system. out. println("john needs " + numbills1 + " bills");
system. out. println("jane needs " + numbills2 + " bills");

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:00
Meenu wants to create a high quality drawing in a variety of colours. which device should she use for the same?
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
On early television stations, what typically filled the screen from around 11pm until 6am? test dummies test patterns tests testing colors
Answers: 1
You know the right answer?
The following code is poorly structured. rewrite it so that it has a better structure and avoids red...
Questions
question
Mathematics, 01.10.2019 05:30
question
Mathematics, 01.10.2019 05:30
question
History, 01.10.2019 05:30
question
Mathematics, 01.10.2019 05:30
question
Mathematics, 01.10.2019 05:30
Questions on the website: 13722363