Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1: Create a project in your IDE, write the name of your project in following format Basim007 Task 2: Create an Interface FileOperations in

Task 1: Create a project in your IDE, write the name of your project in following format Basim007

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 13: Throw the FailException object if a student will get less than 50 marks. (5 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)

(NOTE: The picture is attached only for the format of specific task i.e. Task 8, Task 14, Task 15, Task 17 ONLY)image text in transcribed

Task 8: following data key.txt - Notepad File Edit Format View Help 1110 T T F T T result.txt - Notepad File Edit Format View Help Kasim 001 TETETELETE Ali 002 FIFTETETETE T F T Task 14: @Override public void writeResultFile() {...} output - Notepad File Edit Format View Help Qasim 001 4F Ali 002 6 C 1 Task 15: public void displaykey() {...} public void displayStudent() {...} Task 17: Grader result= new Grader(); result.openFile(); result.readResultFile(); result.readKeyFile(); result.gradeCalculation(); result.displayStudent(); result.writeResultFile(); result.closeFile()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions