Question
The file provided in the code editor to the right contains syntax and/or logic errors. In each case, determine and fix the problem, remove all
The file provided in the code editor to the right contains syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade.
import java.util.*;
public class DebugSix3
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String userNumString;
int userNum, val;
final int MIN = 1;
final int MAX = 20;
System.out.println("Enter a number between " + MIN + " and " + MAX + " inclusive");
userNumString = input.next();
userNum = Integer.parseInt(userNumString);
while(userNum < MIN || userNum > MAX)
{
System.out.println("Number out of range" +
" Enter a number between " + MIN + " and " + MAX + " inclusive");
userNumString = input.next();
userNum = Integer.parseInt(userNumString);
}
for(val = userNum; val >= 1; --val)
{
System.out.print(val + " ");
try{
// sleep for 1 second
Thread.sleep(1000);
}
catch(InterruptedException e) {
e.printStackTrace();
}
// Adjust these numbers for faster or slower performance
}
System.out.println(" Blastoff!");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started