Question: Task 1: Create a project in your IDE, write the name of your project in following format Qasim001BEE3A, means your name, registration number, program name
Task 1: Create a project in your IDE, write the name of your project in following format Qasim001BEE3A, means your name, registration number, program name and section all information should be covered in the project name. (2 Marks).
Task 2: Create an Interface FileOperations in your project that has following five methods (5 marks)
- OpenFile():void
- readResultFile():void
- readKeyFile():void
- writeResultFile():void
- closeFile():void
Task 3: Create an Interface ResultCalculation in your project that has following method (2 Marks)
- gradeCalculation():void
Task 4: Create a class Student that holds the following information (5 marks)
- name:String
- regNo:String
- ans1:String
- ans2:String
- ans3:String
- ans4:String
- ans5:String
- ans6:String
- ans7:String
- ans8:String
- ans9:String
- ans10:String
- answers:String[]
- grade:String
- marks:int
Task 5: Encapsulate the Student class, and Provide the implementation of toString() method in Student class. (2 Marks)
Task 6: Create a custom exception called FailException. (2 Marks)
Task 7: Create a Grader class that will implements the FileOperations and ResultCalculation interface. (2 Marks)
Task 8: Create the text file named key.txt and result.txt in your project directory that has the following data (2 mark)
Task 9: Now write the appropriate code inside OpenFile() method in Grader class that will use Scanner class to Open the key.txt and result.txt file. (2 marks)
Task 10: Now write the appropriate code using Scanner class API inside the readResultFile() method in Grader class, this code will read the data stored in result.txt file that was opened in OpenFile() function. This data will be passed to create the two objects of Student class. For example Qasim will be stored as name of Student object, 001 will be stored as regNo of Student object, T will be stored as ans1 in Student Object, F will be stored in ans2 in Student Object, and so on. After the first line again the same process will repeat and another Student object will be created to store the information written in line 2 of result.txt file. (10 Marks)
Task 11: Now write the appropriate code using Scanner class API inside the readKeyFile() method in Grader class, this code will read the data stored in key.txt file that was opened in OpenFile() function. This data will be stored in an answer key Array. The first digit 10 in the key.txt file will be used to determine the size of answer key array. (5 Marks)
Task 12: Now write the appropriate code inside the method for gradeCalculation(). This code will calculate the marks based on answer key data and the data stored in Student objects. Each correct answer will be awarded 10 marks and each wrong answer will be awarded 0 marks. Based on total marks Assign the appropriate grade letter. (10 marks)
Task 14: Now write the appropriate code using Formatter API inside the writeResultFile() method, this code will write the Name, RegNo, Marks and Grade details into a output.txt file. The output will be in the following format as shown in figure. (10 marks)
Task 15: Write appropriate displayKey() and displayResult() methods in Grader class to show the data stored after reading from file. (5 Marks)
Task 16: Encapsulate the Grader class. (5 marks)
Task 17: write appropriate code inside the closeFile() method that will close the key.txt, result.txt and output.txt files (if already opened) (5 marks)
Task 17: Create a Test class that will have main method. Inside the main method create an object of Grader class and call the functions in the order as shown in figure below. (5 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
