Name: Michael Horsman-Best
Date: 09/04/2018
Class: IT 2249
Unit: 8
1 Insert here a copy of your zip file of all of your NetBeans project files so that it could be unzipped,
loaded and run in another NetBeans:
Insert here a copy of your *.java source code text that you used here (copy and paste source code
here, do not simply insert *.java files):
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
/ package u8a1_2dconsoleregisterforcourse; import java.util.Scanner; /*
* - @author omora
/ public class U8A1_2DConsoleRegisterForCourse { /* - @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here System.out.println(“Michael Horsman-Best’s Unit 8 Assignment.”); Scanner input = new Scanner(System.in); // courses 2d array hold course code and their credit hours
String[][] courses = {
{“IT1006”, “IT4782”, “IT4789”, “IT4079”, “IT2230”, “IT3345”, “IT2249”},
{“6”, “3”, “3”, “6”, “3”, “3”, “6”}
}; // validChoices 2d array holds valid number choices (as strings) selected by user
This study source was downloaded by 100000829725281 from CourseHero.com on 12-15-2021 09:25:46 GMT -06:00
https://www.coursehero.com/file/44609620/Unit-8-Assignment-1docx/ // and their corresponding courses
//e.g String[][] choices = { {“5”, “IT2230”}, {“1”, “IT1006”}, {“6”, “IT3345”} };
String[][] validChoices = {
{“”, “”},
{“”, “”},
{“”, “”}
}; int choice;
int totalCredit = 0;
String yesOrNo = “”; do {
choice = getChoice(courses, input); switch (ValidateChoice(choice, validChoices, totalCredit, courses)) {
case -1:
System.out.println(“Invalid – Your selection of ” +
choice + ” is not a recognized course.”);
break;
case -2:
System.out.println(“Invalid – You have already registerd for this ” +
courses[0][choice-1] + ” course.”);
break;
case -3:
System.out.println(“Invalid – You can not register for more than 9 credit hours.”);
break;
case 0:
System.out.println(“Registration Confirmed for course ” +
courses[0][choice-1] );
totalCredit += Integer.parseInt(courses[1][choice-1]);
if (validChoices[0][0].equals(“”)) {
validChoices[0][0] = Integer.toString(choice);
validChoices[0][0] = courses[0][choice-1];
} else if (validChoices[1][0].equals(“”)) {
validChoices[1][0] = Integer.toString(choice);
validChoices[1][1] = courses[0][choice-1];
} else if (validChoices[2][0].equals(“”)) {
validChoices[2][0] = Integer.toString(choice);
validChoices[2][1] = courses[0][choice-1];
}
break;
}
WriteCurrentRegistration(validChoices, totalCredit);