package CIS115; import java.util.Scanner; public class NestLoops { public static void main(String[] args) { for (int i = 0; i < 3; i = i + 1) { for (int j = 0; j < 3; j = j + 1) { System.out.println(i + " " + j); } } String user = "x"; // dummy value so loop starts // repeat until they quit while (!user.equals("quit")) { int high = promptInt("Count to?"); // count to the chosen number for (int i = 0; i < high; i = i + 1) { System.out.println(i); } user = promptString("again or quit?"); } int highest = -1; // start off lower than legal values int userNum; // ten times for (int count = 0; count < 10; count = count + 1) { // make user repeat until the number is legal do { userNum = promptInt("Enter number from 0 to 100"); } while (userNum < 0 || userNum > 100); // check if this is our new highest number if (userNum > highest) { highest = userNum; } } System.out.println("the highest number was " + highest); } /* Simple Utility methods that prompt the user and return input If you enter the wrong type of input, the program will end with an error! */ // utility for reading in integer input public static int promptInt(String promptText) { System.out.print(promptText + " "); Scanner scan = new Scanner(System.in); int response = scan.nextInt(); return response; } // utility for reading in String input public static String promptString(String promptText) { System.out.print(promptText + " "); Scanner scan = new Scanner(System.in); String response = scan.nextLine(); return response; } }