Computers and Technology

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");

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:20, eagles2286
The reset circuit used on the four 3-bit counters analyzed in this activity reset the counts to zero (000). it makes sense for the up-counters to start at zero (000), but the down-counters should start at seven (111). what would you need to change so that the 3-bit binary down counter with j/k flip-flops you just created would reset to seven (111)?
Answers: 1
image
Computers and Technology, 23.06.2019 00:00, brooklyn4932
What engine component is shown in the above figure?
Answers: 1
image
Computers and Technology, 23.06.2019 00:30, alex7078
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
image
Computers and Technology, 23.06.2019 12:30, umimgoingtofail
What is the difference between the internet and the world wide web?
Answers: 1
Do you know the correct answer?
The following code is poorly structured. rewrite it so that it has a better structure and avoids red...

Questions in other subjects:

Konu
Mathematics, 27.09.2019 03:30
Konu
Mathematics, 27.09.2019 03:30