Objectives Apply OO design technique: allocation of classes and responsibilities. Use OO features: class, instance...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objectives • Apply OO design technique: allocation of classes and responsibilities. Use OO features: class, instance variable, constructor and method to implement the solution. Adopt good programming practices: modular code, appropriate comments, etc. Online Quiz (3 marks) To be announced. Programming Task (4 marks) Write a Java program to allow user to input, save and manipulate a list of test results. A test result includes the applicant Id, name and the two test scores of an applicant taking a test. The program will allow the user to input test result repeatedly until the user indicates to stop. The following screenshot of the program execution illustrates the program flow. You may use an instance of ArrayList to save the results. https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html Candidate Id: C001 : Alice Name Test 1 score: 60 Test 2 score: 85 Enter another record? (y/n) y Candidate Id: C004 : Eric Chan Name Test 1 score: 58 Test 2 score: 74 Enter another record? (y/n) n When the data entry is done, the program will display a list of options as follow. 1 Search test result by applicant Id 2 Search test result(s) by applicant name 3 Search test result(s) by overall score 4 Show test result(s) with highest overall score 5 Show failure list 6 Quit Please choose an option: Option 1 The program will prompt the user to enter an applicant Id, search and display the corresponding test result. The program will display an appropriate message if the there is no matching test result. Option 2 The program will prompt the user to enter an applicant name, search and display the corresponding test result(s). The program will display an appropriate message if the there is no matching test result. Option 3 The program will prompt the user to enter two scores: lower bound and upper bound. The program will display test results whose overall score is between the range (inclusive of both ends). The program will display an appropriate message if the there is no matching test result. Option 4 The program will display test results whose overall score is the same as the highest overall score of the results in the ArrayList. The program will display an appropriate message if the there is no matching test result. Option 5 The program will display test results whose overall score is below the passing marking. The program will display an appropriate message if the there is no matching test result. Option 6 The program will exit the loop and terminate. Class Design The program will consist of two or more classes depending on your design. One class will contain the main method, and is responsible for interacting with the user (input/output) among other things. The TestResult class will include instance variables to store the applicant Id, name and the two test scores. The TestResult class must include appropriate constructor(s), getters, setters and the following methods: • A method to compute the overall score using the formula: o overall score = test score 1 x 40% + test score 2 x 60% • A method to compute and return the grade based on the overall score: o Overall score >= 75 → "Good" o Overall score is between 50 and 74 (inclusive at both ends) → "Pass" o Overall score < 50 → "Fail" • A method to compare two instances of TestResult: o The method will include a parameter of TestResult. o The method will compare the applicant Ids and return true if are the same ld. o https://www.softwaretestinghelp.com/equals-method-in-java/ o https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html You may include additional instance and/or static methods as you deemed fit. Source code comments Please include appropriate header and block comments in the program. Objectives • Apply OO design technique: allocation of classes and responsibilities. Use OO features: class, instance variable, constructor and method to implement the solution. Adopt good programming practices: modular code, appropriate comments, etc. Online Quiz (3 marks) To be announced. Programming Task (4 marks) Write a Java program to allow user to input, save and manipulate a list of test results. A test result includes the applicant Id, name and the two test scores of an applicant taking a test. The program will allow the user to input test result repeatedly until the user indicates to stop. The following screenshot of the program execution illustrates the program flow. You may use an instance of ArrayList to save the results. https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html Candidate Id: C001 : Alice Name Test 1 score: 60 Test 2 score: 85 Enter another record? (y/n) y Candidate Id: C004 : Eric Chan Name Test 1 score: 58 Test 2 score: 74 Enter another record? (y/n) n When the data entry is done, the program will display a list of options as follow. 1 Search test result by applicant Id 2 Search test result(s) by applicant name 3 Search test result(s) by overall score 4 Show test result(s) with highest overall score 5 Show failure list 6 Quit Please choose an option: Option 1 The program will prompt the user to enter an applicant Id, search and display the corresponding test result. The program will display an appropriate message if the there is no matching test result. Option 2 The program will prompt the user to enter an applicant name, search and display the corresponding test result(s). The program will display an appropriate message if the there is no matching test result. Option 3 The program will prompt the user to enter two scores: lower bound and upper bound. The program will display test results whose overall score is between the range (inclusive of both ends). The program will display an appropriate message if the there is no matching test result. Option 4 The program will display test results whose overall score is the same as the highest overall score of the results in the ArrayList. The program will display an appropriate message if the there is no matching test result. Option 5 The program will display test results whose overall score is below the passing marking. The program will display an appropriate message if the there is no matching test result. Option 6 The program will exit the loop and terminate. Class Design The program will consist of two or more classes depending on your design. One class will contain the main method, and is responsible for interacting with the user (input/output) among other things. The TestResult class will include instance variables to store the applicant Id, name and the two test scores. The TestResult class must include appropriate constructor(s), getters, setters and the following methods: • A method to compute the overall score using the formula: o overall score = test score 1 x 40% + test score 2 x 60% • A method to compute and return the grade based on the overall score: o Overall score >= 75 → "Good" o Overall score is between 50 and 74 (inclusive at both ends) → "Pass" o Overall score < 50 → "Fail" • A method to compare two instances of TestResult: o The method will include a parameter of TestResult. o The method will compare the applicant Ids and return true if are the same ld. o https://www.softwaretestinghelp.com/equals-method-in-java/ o https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html You may include additional instance and/or static methods as you deemed fit. Source code comments Please include appropriate header and block comments in the program.
Expert Answer:
Answer rating: 100% (QA)
Below is a simple implementation in Java based on the requirements youve provided Ive created two cl... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Which annotations will trigger a compiler error if incorrectly applied to a method with no other annotations? (Choose three.) A. @Documented B. @Deprecated C. @SuppressWarnings("unchecked") D....
-
Naleid and colleagues (2008) asked how the interaction of the ingredients corn oil and sucrose enhanced liking for vanilla milkshakes. To test this, rats responded on a lever to gain access to...
-
Jain Corp. has negotiated a lease for new machinery. Jain Corp. is excited about the new products it will be able to produce with this machinery at gross margins much higher than historical levels....
-
The following scenarios describe situations faced by hypothetical companies that currently have a centralized organization structure. As you review each of the scenarios, provide your opinion as to...
-
Smart Video Company is a manufacturer of videoconferencing products. Maintaining the videoconferencing equipment is an important area of customer satisfaction. A recent downturn in the computer...
-
Briefly explain the differences between a stand alone query language, embedded query language and a data manipulation language.
-
How do advanced theories of globalization, such as the global production network (GPN) framework, network theory, and world-systems theory, provide insights into the evolving dynamics of global...
-
REFLECTION PAPER 1. Select an issue in your community. What community trends might have led to the development of this issue, and what would your proposed solution be? Finally, why is this important...
-
For the function f(x) = 5 3 apply the definition of the derivative. Evaluate each of the following and enter your answers in simplest form: Step 1 f(x + h) = Preview Step 2 f(x+ h) f(x) = Preview f(x...
-
A 8.5 kg block of ice with a temperature of -10 C is placed on a large stone slab with a temperature of +10 C. The stone slab is so large that its temperature does not change. The ice and the slab...
-
In preparation for expert witness testimony in court, the fraud examiner or forensic accountant should understand that the opposing lawyer will NOT: Question 14 options: a) Learn your field b) Agree...
-
What is the United States child and dependent care credit ? how has this credit change within a year?
-
There are different types of non-probability sampling methods. Below are examples of such methods. You are required to go through them and (for each example); a. Name the Sample Method b. Write a not...
-
If there is an unrealized holding gain on available-for-sale investments, it is reported as?
-
Modify the ClockPane class with three new Boolean properties?hourHandVisible, minuteHandVisible, and secondHandVisible?and their associated accessor and mutator methods. You can use the set methods...
-
Write a program that displays the following table. Cast floatingpoint numbers into integers. pow (a, b) 2 2 3 4 81 1024 15625
-
Write a program that draws a fixed rectangle centered at (100, 60) with width 100 and height 40. Whenever the mouse is moved, display a message indicating whether the mouse point is inside the...
-
What challenges is Lidl likely to face in the coming years?
-
Give some examples of things we might learn about the likely behaviour and performance of businesses in an industry by knowing something about the industrial concentration of that industry.
-
Consider a country other than the UK and investigate the changes in its industrial structure. Are the changes similar to or different from those in the UK?
Study smarter with the SolutionInn App