Write a program that requires the user to enter an integer at run time, representing the exam results of a course, followed by a "fail", "Pass", "Medium", "good", "excellent" conclusion.
Requires that the program be robust enough that it does not crash regardless of what the user enters.
Import java.util.*;
public class Mark {
public static void Main (string[] args)
{
Scanner SC =new Scanner (system.in);
int score=0;
System.out.print ("Please enter your score:");
Try
{
Score=sc.nextint ();
if (score>=0&&score<=59)
{
SYSTEM.OUT.PRINTLN ("fail");
}
if (score>=60&&score<=69)
{
SYSTEM.OUT.PRINTLN ("Pass");
}
if (score>=70&&score<=79)
{
System.out.println ("Medium");
}
if (score>=80&&score<=89)
{
System.out.println ("Liang");
}
if (score>=90&&score<=100)
{
System.out.println ("excellent");
}
if (score<0| | SCORE>100)
{
System.out.println ("The number entered is too large or too small");
}
Else
{
System.out.println ("");
}
}
catch (Exception e)
{
System.out.println ("Please enter the correct number:");
}
}
}
Java polymorphism and exception handling--hands-on brain