Advertisement
RazorBlade57

Grade

Nov 14th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. //Β© A+ Computer Science  -  www.apluscompsci.com
  2. //Name -
  3. //Date -
  4. //Class -
  5. //Lab  -
  6.  
  7. import static java.lang.System.*;
  8.  
  9. public class Grade
  10. {
  11.     private int numGrade;
  12.  
  13.     public Grade()
  14.     {
  15.         numGrade = 100;
  16.     }
  17.  
  18.     public Grade(int grade)
  19.     {
  20.         numGrade = grade;
  21.     }
  22.  
  23.     public void setGrade(int grade)
  24.     {
  25.         numGrade = grade;
  26.     }
  27.  
  28.     public char getLetterGrade(int x, char word)
  29.     {
  30.         if(x>90){
  31.                word='A';
  32.             }
  33.             else if(x>80){
  34.                word = 'B';
  35.             }
  36.             else if(x>70){
  37.                word ='C';
  38.             }
  39.             else if(x>60){
  40.                    word ='D';
  41.                 }
  42.             else if(x>50){
  43.                    word ='F';
  44.                 }
  45.  
  46.  
  47.         char letGrade= word;
  48.         return letGrade;
  49.     }
  50.  
  51.     public String toString()
  52.     {
  53.         return numGrade + " is a " + getLetterGrade() + "\n";
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement