Connect with experts and get insightful answers on IDNLearn.com. Whether it's a simple query or a complex problem, our experts have the answers you need.
The following code is not robust against invalid user input. Describe how to change the code so that it will not proceed until the user has entered a valid age and grade point average (GPA). Assume that any int is a legal age and that any double is a legal GPA.
Scanner console = new Scanner(System.in); System.out.print("Type your age: "); int age = console.nextInt(); System.out.print("Type your GPA: "); double gpa = console.nextDouble(); For an added challenge, modify the code so that it rejects invalid ages (for example, numbers less than 0) and GPAs (say, numbers less than 0.0 or greater than 4.0).
Sagot :
Your presence in our community is highly appreciated. Keep sharing your insights and solutions. Together, we can build a rich and valuable knowledge resource for everyone. Discover insightful answers at IDNLearn.com. We appreciate your visit and look forward to assisting you again.