Java polymorphism and exception handling-start-to-brain and java polymorphism Exception Handling
Write a program that requires the user to enter an integer at run time to represent the test score of a course, the program then gives the conclusion of "fail", "pass", "medium", "good", and "excellent.
Requires that the program be robust enough, no matter what content the user inputs, it will not crash.
Import java. util .*;
Public class Mark {
Public static void main (String [] args)
{
Pipeline SC = new pipeline (System. in );
Int score = 0;
System. out. print ("Enter the 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 ("good ");
}
If (score> = 90 & score <= 100)
{
System. out. println ("excellent ");
}
If (score <0 || score> 100)
{
System. out. println ("the input number is too large or too small ");
}
Else
{
System. out. println ("");
}
}
Catch (Exception e)
{
System. out. println ("enter the correct number :");
}
}
}