CIS 265 Data Structures and Algorithms
Assignment 3
Due: 12:24pm, Tue, Feb. 16, 2021
100 points
I. Description
In this assignment, you will add input checking in the program in assignment 2. A valid student ID should
be an integer between 1000000 and 9999999. A valid student GPA should be a double between 0 and 4.0.
No other function is added to the program in assignment 2.
1. The program will first ask the user to input the number of students to be created. If the user
inputs a value in wrong format, such as a double or string, the program should print an error
message “Please input a number between 1 and 10.” The number should be from 1 to 10.
Otherwise, the program prints “I cannot create xxx students!” where xxx is the input number.
If the input is in wrong format or outside the range, the program should ignore the input and
prompt again.
2. When the program prompts the user for student ID, if the user input a value in wrong format
or an invalid value, it will print an error message “Please input an integer between 1000000
and 9999999.”,
ignore the input, and prompt again.
3. When the program prompts the user for student GPA, if the user input a value in wrong
format or an invalid value, it will print an error message “Please input a valid GPA (0-4.0)”,
ignore the input, and prompt again.
4. After the input of the Student objects, the program will then search the student array. It keeps
asking the user for a student ID. If the user inputs 0, the program will print “Goodbye!” and
exit. If the user does not input an integer, the program should print an error message, “Please
input an integer between 1000000 and 9999999”. If the user inputs an integer but an invalid
ID, the program will a message, “A valid ID is an integer between 1000000 and 9999999”. In
both cases, the program will ignore the input and prompt the user again.
5. If the user inputs a valid ID, the program will search the student array for the given student
ID. If a match is found, the program will call printStudent() to print the student information.
If no match is found, the program prints “Student ID xxxx not found.” where xxxx is the ID
given by the user.
6. Since the student array may not be sorted, you should use linear search.
7. A sample run will look like this where the green texts are user inputs:
How many students do you have(1-10): two
Please input a number between 1 and 10.
How many students do you have(1-10): 0
I cannot create 0 students!
How many students do you have(1-10): 11
I cannot create 11 students!
How many students do you have(1-10): 2
Student 1 name:Si Ti
Student 1 ID:oneone
Please input an integer between 1000000 and 9999999
Student 1 ID:2021
Please input an integer between 1000000 and 9999999
Student 1 ID:999999
Please input an integer between 1000000 and 9999999
Student 1 ID:10000000
Please input an integer between 1000000 and 9999999
Student 1 ID:1000000
Student 1 GPA:good
Please input a valid GPA (0-4.0)
Student 1 GPA:4.11
Please input a valid GPA (0-4.0)
Student 1 GPA:-0.0000001
Please input a valid GPA (0-4.0)
Student 1 GPA:2
Student 2 name:Sa Li
Student 2 ID:9999999
Student 2 GPA:4
Enter a valid student ID (enter 0 to quit): not sure
Please input an integer between 1000000 and 9999999
Enter a valid student ID (enter 0 to quit): 1000
A valid ID is an integer between 1000000 and 9999999
Enter a valid student ID (enter 0 to quit): 1000000
Student name:Si Ti
Student ID:1000000
Student GPA:2.0
Enter a valid student ID (enter 0 to quit): 9999999
Student name:Sa Li
Student ID:9999999
Student GPA:4.0
Enter a valid student ID (enter 0 to quit): 0
Goodbye.
II. General Requirements
• Your program must include two Java files, one for the main class and the other for the
Student class. You may reuse the Student class from Assignment 2.
• Both classes must be in the same package. The package name should start with your last
name, e.g., FuCIS265.
• Please name your main class file under your last name. For example, if your last name is
“Fu”, your file name should start with “Fu”, e.g., FuAssignment3.java.
• The Scanner’s nextInt() or nextDouble() method does NOT read the newline character. You
need to call a nextLine() after nextInt() or nextDouble() to discard the newline character.
• It is essential that you use nextLine() to discard the wrong input in the catch statement.
Otherwise, your program may go to infinite loop.
• I suggest you break the input processing into multiple methods.
III. Submission
This is an individual assignment. Each student needs to submit the source code files of the Java
program on Blackboard.
1. You must submit a zip file of the package, i.e., the folder with your source files.
2. You need to submit only the source code, i.e., the Java files.
3. You may submit multiple time. Your most recent submission before the deadline will be
graded.
IV. Grading
1. A program that does not run will receive 0 point.
2. There is a 10-20 points deduction for each major error, e.g., do not find a student.
3. There is a 1-9 points deduction for each minor error, e.g., a spelling error in printed message.
4. A program that does not follow the guidelines will lose 1-10 points.
5. Any type of cheating is not tolerated. You may be asked to explain your program in person.
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.
Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.
We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.