/******************************************************************
 ** This program illustrates the SWITCH statement. **
 ******************************************************************/
import java.io.*;

public class SwitchStatement
{

  public SwitchStatement()
  {
    double   Test_1, Test_2, Test_3;
    int      Average;
    System.out.println("\n\n\nEnter three test score between 0 - 100");
    System.out.print("Please Enter First test score  ====> ");
    Test_1 = ReadPositiveIntFromKeyBoard();
    System.out.print("Please Enter Second test score ====> ");
    Test_2 = ReadPositiveIntFromKeyBoard();
    System.out.print("Please Enter Third test score  ====> ");
    Test_3 = ReadPositiveIntFromKeyBoard();
    if(  (Test_1 > 100) || (Test_2 > 100) || (Test_3 > 100)
      || (Test_1 < 0)   || (Test_2 < 0)   || (Test_3 < 0)
      )
    {
      System.out.print("Error - No Test Score should be graeter than");
      System.out.println(" 100 or less than zero");
      return;
    }
    Average = (int)(((Test_1 + Test_2 + Test_3) / 3.0) / 10);
    switch (Average)
    {
      case 0 :
      case 1 :
      case 2 :
      case 3 :
      case 4 :
      case 5 :
           System.out.println("Failing Grade with an average   = "
                                      + Average * 10);
           break;
      case 6 :
           System.out.println("You got D Grade with an average = "
                                      + Average * 10);
           break;
      case 7 :
           System.out.println("You got C Grade with an average = "
                                      + Average * 10);
           break;
      case 8 :
           System.out.println("You got B Grade with an average = "
                                      + Average * 10);
           break;
     case 9 :
     case 10:
           System.out.println("You got A Grade with an average = "
                                      + Average * 10);
           break;
     default:
          System.out.println("This is the default case, there must be an error");
    }  /* end of switch statement */
  }
  //****************************************************
  public int ReadPositiveIntFromKeyBoard()
  {
    int   InputByte;
    int   Total = 0;

    try
    {
       InputByte = System.in.read();
       // skip carriage return
       if(   ('\n' == InputByte)
         ||  ('\r' == InputByte)
         )
         InputByte = System.in.read();
    }
    catch(IOException MyIOException)
    {
      return (0);
    }
    while(  (InputByte >= '0')
        &&  (InputByte <= '9')
         )
    {
      Total = (Total * 10)  + (InputByte - ('0'));
      try
      {
        InputByte = System.in.read();
      }
      catch(IOException MyIOException)
      {
        return (Total);
      }
    }
    return(Total);
  }    // ReadPositiveIntFromKeyBoard
  //****************************************************
  public static void main(String [] args)
  {
    SwitchStatement  MySwitchStatement = new SwitchStatement();
	 try
	 {
		 int returnKey;
		 returnKey =  System.in.read();
		 if(   ('\r' == returnKey)
			|| ('\n' == returnKey)
			)
		   System.in.read();
	 }
	 catch(Exception MyException)
	 {
		 //do nothing
	 }
  }
}



