Question: The following program works, but its ugly. Modify it to perform the same function with a more conventional while loop. import java.util.Scanner; public class Test

The following program works, but it’s ugly. Modify it to perform the same function with a more conventional while loop.

import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner stdIn = new

import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner stdIn = new Scanner (System.in); String all Entries=""; for (String entry=""; ;) { System.out.print("Make entry or 'q' to quit: "); entry if (entry.equals("q")) break; else allEntries += " + entry; } // end for = stdIn.nextLine(); System.out.println(allEntries); } // end main } // end class Test

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The given Java program uses a for loop without its usual initialization condition and increment expr... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!