IT 2249 Unit 10 Assignment- Capella University | LATEST UPDATE | GRADED A
IT 2249 Unit 10 Assignment- Capella University | LATEST UPDATE | GRADED A Date: 3/18/2022 Unit: 10 Assignment 1 1 When you submit your assignment, attach the complete, zipped NetBeans project (not just the .java file) to your submission and attach a completed copy of thi s submission template as a second attachment. (Please do not embed the zip file in this document.) For u03a1, u06a1, u08a1, and u10a1: Be sure to turn in the zip file with code that you have completed, not the original zip file downloaded from the resources. 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 u10a1_ooconsoleregisterforcourse; import .Scanner; /** * * @author rali */ public class U10A1_OOConsoleRegisterForCourse { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Sln("Richard's Copy"); Scanner input = new Scanner(S); //Courses is an array of course objects //see the C source code for members of Course Course[] courses = { new Course("IT1006", 6), new Course("IT4782", 3), Capella Proprietary and Confidential 1 new Course("IT4789", 3), new Course("IT4079", 6), new Course("IT2230", 3), new Course("IT3345", 3), new Course("IT2249", 6) }; //choice is the number selected by the user int choice; int totalCredit = 0; String yesOrNo = ""; do { choice = getChoice(courses, input); switch (ValidateChoice(choice, totalCredit, courses)) { case -1: Sln("**Invalid** - Your selection of " + choice + " is not a recognized course."); break; case -2: Sln("**Invalid** - You have already registerd for this " + courses[choice-1].getCode() + " course."); break; case -3: Sln("**Invalid** - You can not register for more than 9 credit hours."); break; case 0: Sln("Registration Confirmed for course " + courses[choice-1].getCode() ); totalCredit += courses[choice-1].getCreditHour(); courses[choice-1].setIsRegisteredFor(true); break; } WriteCurrentRegistration(courses, totalCredit); S("nDo you want to try again? (Y|N)? : "); yesOrNo = ().toUpperCase(); } while (yesOrNs("Y")); Sln("Thank you for registering with us"); } //This method prints out the selection menu to the user in the form of //[selection number]Course Code (Course Credit Hours) //from the courses array one per line //and then prompts the user to make a number selection public static int getChoice(Course[] courses, Scanner input) { Sln("Please type the number inside the [] to register for a course"); Sln("The number inside the () is the credit hours for the course"); for(int i = 0; i < h; i++){ Sln("[" + (i+1) + "]" + courses[i].getCode()+ "(" + courses[i].getCreditHour()+ ")"); } // TO DO // loop over the courses array and print out the attributes of its //objects in the format of //[selection number]Course Code (Course Credit Hours) //one per line S("Enter your choice : "); return (Int()); } //This method validates the user menu selection //against the given registration business rules //it returns the following code based on the validation result // -1 = invalid, unrecognized menu selection // -2 = invalid, alredy registered for the course // -3 = invalid, No more than 9 credit hours allowed // 0 = menu selection is valid public static int ValidateChoice(int choice, int totalCredit, Course[] courses) { if (choice < 1 || choice > 7) return -1; else if (IsRegisteredBefore(choice, courses) ) return -2; else if ( (totalCredit + courses[choice-1].getCreditHour()) > 9) return -3; return 0; } //This method checks the courses array of course object to //see if the course has already been registered for or not public static boolean IsRegisteredBefore(int choice, Course[] courses) { for(int i = 0; i < h; i++) if(courses[choice-1].getIsRegisteredFor() == true) return true; return false; } //This method prints the current list of registered courses thus far //from the courses array separated by , and enclosed inside { } //It also prints the total credit registered for thus far public static void WriteCurrentRegistration(Course[] courses, int totalCredit) { S("Current course registration: { " ); boolean printComma = false; for(int i = 0;i < h; i++){ if(courses[i].getIsRegisteredFor() == true){ if (printComma == true){ S(", "); } S(courses[i].getCode()); printComma=true; } } // TO DO // loop over the courses array, determine which courses are registered //for thus and print them out in the format of //{ list of courses separated by , } Sln(" }" ); Sln("Current registration total credit = " + totalCredit); } } 2 Insert screenshot(s) here showing the result of testing your application as directed by the assignment instructions. (Programs with more than 1 possible outcome require screen shots to show that the different possible outcomes work as required.) 3 Describe your approach to complete the coding for this assignment and explain the major decisions you made in designing a program that meets the specified requirements. As part of your explanation, be sure to identify the Java constructs you used that are specific and relevant to your program. Depending on the program, these may include the mechanisms for output, input, selection statements, loops, methods, and so forth. In units 9 and 10, be sure to discuss the classes used in the application. (Please do not just list Java keywords or snippets of code without indicating why they are important.) For this week’s assignment we were tasked with completing the programming of two Java class methods in a console application that registers students for courses in a term of study. In one method, the code prints out a list of courses available for registration and prompt the user to select a course for which to register and in the second method, the code prints out a current list of registered courses and their total credit hours. The program needed to follow the following rules: No registration of other courses not displayed by the program , no registration more than once for the same course and no registration for more than 9 credit hours (e.g. no more than 3 courses). Since the professor provided the first part of the source code my first step was to download and unzip the existing project (U10A1_OOConsoleRegisterForC) and load it into NetBeans. Once the project was opened in NetBeans, I needed to enter code into the program using the getChoice() and the WriteCurrentRegistration() methods to meet the requirements. For me to do this I used the BooLean method for the sections that needed coding. After setting up the BooLean method I used For statements for loops to run the array in the courses along with the total credit hours. As you can see in lines 89-92 there was a public class used for the course choice(getChoice) (public static int getChoice) and the BooLean method runs courses array of the course object. This method helped to determine courses that were registered for and terminated the input unless the code produces an error during registration. Next, for lines 138-147 in the program there was a public class used for the course registration(WriteCurrentRegistration) (public static void WriteCurrentRegistration) and the BooLean method was entered and used to determine the codes format and prints the comma at the end of the course name and terminate if no course is chosen after the selection. The For loop was used to run the courses array confirming which courses had been registered for along with the total sum of the credit hours for the courses registered. When I ran the program, I first registered for “IT2230” which was 3 credits and confirmed registration of the course with 3 credit hours. Next, I registered for “IT2249” which was 6 credit hours confirmed registration of the course. It also printed out that now I had registered for both “IT2230” and “IT2249” for a total of 9 credit hours. Next, I had to continue testing the program to ensure my code met the requirements, so my next step was to try registration of “IT2230” again, and the program returned the result of letting me know that I had already registered for this course. Lastly, I tested the program code to ensure it would not let me register for more than 9 credit hours. I attempted to register for “IT3345” and the program informed me that I cannot successfully register for more than 9 credit hours. As you can see from my code along with my screenshots you can see that I successfully wrote code to register for the courses for a total of 9 credit hours and did meet the requirements set by the professor. Show Less
Written for
- Institution
-
Capella University
- Course
-
IT 2249
Document information
- Uploaded on
- October 11, 2022
- Number of pages
- 12
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
- attach the complete
-
it 2249 unit 10 assignment capella university | latest update | graded a
-
when you submit your assignment
-
zipped netbeans project not just the java file to your submission and