Question: (Java) My code is good so far, but am still missing some components. How do I use the sentinel loop pattern to ask the user


1 package com.company; 2 3 import java.util.Scanner; class scratch { //Class Name 6 public static void main(String[] args) { Scanner input = new Scanner(System.in); 7 8 9 int max, min, guess, secret, maxAttempts = 0; 10 11 System.out.println("What would be the low range: "); min = input.nextInt(); 12 13 14 System.out.println("high range: "); max = input.nextInt(); 15 16 17 secret = (int) (Math.random() * (max - min + 1) + min); //Secret Number System.out.println("Please pick a number between " + min + "." + max); 18 19 20 21 while (maxattempts secret) { System.out.println("Too high"); System.out.println("Please pick a number between + guess); } else { System.out.println("Congrats"); } maxAttempts++; 31 32 e 33 34 e 35 36 11 + secret); 38 System.out.println("The number was 39 } 40 41 42 } 43 YOUT yuess 15 222 Too low Please pick a number between 222-500 Your guess is: 111 Too low Please pick a number between 111-500 Your guess is: I 44 1. Structure Too low Please pick a number between 44-500 The number was 321 Bookmarks Process finished with exit code Bulld Problems Terminal Run Warrion Control 1E TODO
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
