Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rules:
- You may NOT use any other resources other than your IDE and the Java Documentation website to solve this problem.
- The only other website you may visit is our BrightSpace course for the purpose of submitting your solution and reading these instructions.
- You may have one-side of one page of hand-written notes beside you, your name and student number must appear on one of the sides.
- Differences from the requirements below, will result in marks removed so pay close attention.
- Compile errors will result in a 0, so code in small iterations, compile and test often.
- Compile warnings will decrease your mark so ensure they are all addressed prior to handing in your solution.
- Anything displayed inside <> brackets included, should be replaced with real values. For example, <input> would be replaced with 7 if the user input into the keyboard a 7.
- Your programming style will be evaluated so maintain your indentation and such
- Javadoc and other comments will not be evaluated.
- On your laptop:
- Open your IDE; create a NEW WORKSPACE called c:\CST8130Exam
- Note – if you are working on a MAC, choose an appropriate name rather directly in the root directory
- Classes to Create:
- create a new Project called MyNameLabTest (for example, MelissaSienkiewiczLabTest), all classes MUST be added to the default package.
- create a new class with method main called LabTest
- create another new class called Student
- data members include: studentNumber (int), studentName (String) and balance (float)
- create another new class called CollegeRegistrar
- data members include: students (ArrayList of Students), name (String)
- Programming Instructions:
- Using Object Oriented Principles, write a program which produces the code as indicated in the following specifications:
- Your program must be a console application that provides a user this exact menu:
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: <keyboard input here>
- The menu must be displayed repeatedly until 5 is selected
- If the user enters an invalid menu choice, you must display the error "Unsupported choice" and display the menu again.
- When the user selects menu item 1:
- The program will read data from the keyboard to create a new Student and add it to the CollegeRegistrar, the user will be asked to input as follows:
- Please Enter the Student's Name: <keyboard input here>
- Please Enter the Student Number: <keyboard input here>
- Please Enter the Student's Balance: <keyboard input here>
- If invalid input is encountered, the error message "Incorrect format" must be displayed and input is terminated, the student is not created nor added to the CollegeRegistrar. The menu should then be displayed again.
- The student list must remain in sorted order by Student Number, you may use the Collection class methods or do this manually. The more efficient you are, the higher your mark.
- You are able to create a get method for studentNumber if you deem this necessary.
- To simplify this exam, ignore the issues that could occur if a duplicate studentNumber is specified. Do not test your code with duplicate studentNumbers and neither will I.
- When the user selects menu item 2:
- The program will display the following information:
- College Registrar Information:
- Name: <display business name here>
- Student List:
- Student #: <student number>, Name: <student name>, Balance: $<balance>
- Student #: <student number>, Name: <student name>, Balance: $<balance>
- Student #: <student number>, Name: <student name>, Balance: $<balance>
- ...
- If no College Registrar name is set yet, "Unknown" must be displayed
- If no students are added to the College Registrar yet, "No Students in College Registrar" must be displayed
- When the user selects menu item 3:
- The program will read data from the keyboard to set the name of the college registrar, the user will be asked to input as follows:
- Please Enter the College Registrar's Name: <keyboard input here>
- Consider any non-blank input a valid name.
- When the user selects menu item 4:
- The program will read data from the keyboard to search for a student given the student number, the user will be asked to input as follows:
- Please Enter the Student Number to Search for: <keyboard input here>
- If invalid input is entered, the error message "Incorrect format" must be displayed and no search is performed. The main menu must be displayed.
- The search should be performed using the most efficient search you know, you are able to use Collection class methods or create your own.
- If the search does not succeed, the message "Student not found in College Registrar" must be displayed.
- If the search succeeds, the following message should be displayed where index is filled in with the zero based index where the student is stored in the Student List:
- Student found at index <index>
- Student #: <student number>, Name: <student name>, Balance: $<balance>
- When the user selects menu item 5:
- The program must display the message "Exiting..." and then terminate/end the program.
- Sample Output: green is user input
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 2
- College Registrar Information:
- Name: Unknown
- Student List:
- No Students in College Registrar
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 1
- Please Enter the Student's Name: Melissa Sienkiewicz
- Please Enter the Student Number: 112233
- Please Enter the Student's Balance: $1150
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 1
- Please Enter the Student's Name: Tom Sienkiewicz
- Please Enter the Student Number: 112231
- Please Enter the Student's Balance: $100
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 1
- Please Enter the Student's Name: Jakub Sienkiewicz
- Please Enter the Student Number: 112232
- Please Enter the Student's Balance: $10000.99
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 3
- Please Enter the College Registrar's Name: Algonquin College
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 2
- College Registrar Information:
- Name: Algonquin College
- Student List:
- Student #: 112231, Name: Tom Sienkiewicz, Balance: $100.00
- Student #: 112232, Name: Jakub Sienkiewicz, Balance: $10000.99
- Student #: 112233, Name: Melissa Sienkiewicz, Balance: $1150.00
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 4
- Please Enter the Student Number to Search for: 112232
- Student found at index 1
- Student #: 112232, Name: Jakub Sienkiewicz, Balance: $10000.99
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 4
- Please Enter the Student Number to Search for: 1
- Student not found in College Registrar
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 4
- Please Enter the Student Number to Search for: 200000
- Student not found in College Registrar
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 6
- Unsupported choice
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: e
- Your choice is invalid
- Please select one of the following:
- 1: Add Student to College Registrar
- 2: Display Students in the Registrar
- 3: Set College Registrar Name
- 4: Search for a Student
- 5: Exit
- Enter your Selection: 5
- Exiting...
- Submission Instructions:
- Create a zip file of your workspace directory (zip the directory c:\CST8130Exam or comparable Mac folder)
- Upload the zip file to Brightspace, please note, that only one zip file is permitted and only the one submission is allowed
- Celebrate, you are done!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement