brainfrz

CourseInfoTester

Feb 12th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. public class CourseInfoTester
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         CourseInfo course;
  6.         String prefix, number;
  7.         int credits;
  8.         double grade;
  9.  
  10.         Library64 myLib   = new Library64();
  11.  
  12.  
  13.         System.out.print("\tEnter a course prefix: ");
  14.         prefix = Keyboard.readString().toUpperCase();
  15.         while (prefix.isEmpty() || prefix.length() > 3)
  16.         {
  17.             System.out.print("\tInvalid prefix. Enter a course prefix (1-3 characters): ");
  18.             prefix = Keyboard.readString().toUpperCase();
  19.         }
  20.  
  21.         System.out.print("\tEnter a course number: ");
  22.         number = Keyboard.readString().toUpperCase();
  23.         while (number.isEmpty() || number.length() > 3)
  24.         {
  25.             System.out.print("\tInvalid number. Enter a course number (1-3 characters): ");
  26.             number = Keyboard.readString().toUpperCase();
  27.         }
  28.  
  29.         System.out.print("\tEnter grade point:     ");
  30.         grade = Keyboard.readDouble();
  31.         while (grade < CourseInfo.MIN_GRADE_POINT || grade > CourseInfo.MAX_GRADE_POINT)
  32.         {
  33.             System.out.print("\tInvalid number. Enter grade point (0.0 - 4.0): ");
  34.             grade = Keyboard.readDouble();
  35.         }
  36.  
  37.         System.out.print("\tEnter credit hours:    ");
  38.         credits = Keyboard.readInt();
  39.         while (credits < CourseInfo.MIN_CREDITS || credits > CourseInfo.MAX_CREDITS)
  40.         {
  41.             System.out.print("\tInvalid number. Enter credit hours (1 - 4): ");
  42.             credits = Keyboard.readInt();
  43.         }
  44.  
  45.  
  46.         course = new CourseInfo(prefix, number, grade, credits);
  47.        
  48.         myLib.clrscr();
  49.        
  50.         System.out.println("\n                                  Course List");
  51.         System.out.println("                Spring 2016");
  52.         System.out.println("                    Course      Grade    Credits    Grade Point");
  53.         System.out.println("                    " + course);
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment