Schedule - public class Schedule cfw_ public static void...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Schedule { public static void main(String[] args) { String[] course; String[] days; int[] credits; System.out.println("What is the maximum number of classes a student is permitted to take?"); int maxClasses = IO.readInt(); if (maxClasses < 1) { System.out.println("Student must be allowed to take at least one class."); IO.reportBadInput(); return; } System.out.println("What is the maximum number of credits a student is permitted to carry?"); int maxCredits = IO.readInt(); if (maxCredits < 1) { System.out.println("Student must be allowed to carry at least one credit."); IO.reportBadInput(); return; } course = new String[maxClasses+1]; days = new String[maxClasses+1]; credits = new int[maxClasses+1]; while (true) { System.out.println("Menu:"); System.out.println("1. View current schedule"); System.out.println("2. Get total credits taken"); System.out.println("3. Add a course"); System.out.println("4. Drop a course"); System.out.println("5. Quit"); System.out.println(""); System.out.println("Enter choice:"); int choice = IO.readInt(); if (choice == 1) { String tempClass; int classes = 0; for (int i = 0; i < maxClasses; i++) { if(course[i] != null) { classes++; } } while (classes > 0)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ boolean change = false; for (int i = 0; i < classes-1; i++) { if (course[i].compareToIgnoreCase(course[i+1]) > 0) { tempClass = course[i]; course[i] = course[i+1]; course[i+1] = tempClass; change = true; } } if (change == false)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/03/2009 for the course CS 01-111 taught by Professor Pradiphari during the Fall '09 term at Rutgers.

Page1 / 6

Schedule - public class Schedule cfw_ public static void...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online