/******************************************************************
 ** This program illustrates the if - else statements. It also illustrates
 ** the logical operators AND "&&" and OR "||"
 ******************************************************************/
import java.io.*;

public class IfElseStatements
{

  public IfElseStatements()
  {
      int       Test_1, Test_2, Test_3;
      int       Average;
      int       HighestTest = 0;

      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 Thirs 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);
      if(Average < 6)
        System.out.println("Failing Grade with an average   = "
                                + Average * 10);
      else
        if( (Average >= 6) && (Average < 7))
          System.out.println("You got D Grade with an average = "
                                 + Average * 10);
        else
          if( (Average >= 7) && (Average < 8))
            System.out.println("You got C Grade with an average = "
                                   + Average * 10);
          else
            if( (Average >= 8) && (Average < 9))
              System.out.println("You got B Grade with an average = "
                                     + Average * 10);
            else
              if( (Average >= 9) && (Average < 11))
                System.out.println("You got A Grade with an average = "
                                      + Average * 10);
             else   //*  default:
               {
                 System.out.print("This is the default case, ");
                 System.out.println("there must be an error");
               }

      HighestTest = (HighestTest < Test_1)? Test_1: HighestTest;
      HighestTest = (HighestTest < Test_2)? Test_2: HighestTest;
      HighestTest = (HighestTest < Test_3)? Test_3: HighestTest;
      System.out.println("\n\n Highest Test = " + HighestTest);
  }
  /****************************************************/
  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)
    {
      IfElseStatements  MyIfElseStatements  = new IfElseStatements();
	 try
	 {
		 int returnKey;
		 returnKey =  System.in.read();
		 if(   ('\r' == returnKey)
			|| ('\n' == returnKey)
			)
		   System.in.read();
	 }
	 catch(Exception MyException)
	 {
		 //do nothing
	 }
  }
}
