Question: The following code is poorly structured: Rewrite it so that it has a better structure and avoids redundancy. You may wish to introduce a method
The following code is poorly structured:

Rewrite it so that it has a better structure and avoids redundancy. You may wish to introduce a method to help capture redundant code.
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); %3D if (numBills1 * 20.0 < amount) { numBills1++; } System.out.print ("How much will Jane be spending? "); amount = console.next Double (); 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");
Step by Step Solution
3.46 Rating (166 Votes )
There are 3 Steps involved in it
Refactored code to reduce redundancy Prompts for two peoples m... View full answer
Get step-by-step solutions from verified subject matter experts
