Jordan University of Science and TechnologyCS415 Contemporary Programming TechniquesMidterm Exam – Second semester 2021Name: ID: Section:Important note: your code must compile correctly and run without errors.Otherwise your code will get the grade zero.Question 1: Implement a java class called ParsingCustomerRecords that has thefollowing data members and functions:ParsingCustomerRecods- customerRecords: array of strings- result: string variable- recordsNumber: int variable-fileName: string variable+ Constructor(String filename, int recordsNumber)+ void Reader()+ void Executor()+ void showResult()+ String toString()All of the data members are private, and all of the methods are public.Constructor has two parameters which are (1) the file name in which Customers’ recordsare stored, and (2) the number of the records in the file. The constructor functionality is toassign suitable initial values to the fileName and recordsNumber data members. Theconstructor also should instantiate the customerRecords array, where the size of the arrayshould be equal to recordsNumber.Reader is a void method that reads the Customers’ records file line by line and storeseach record (i.e., each line) at distinct index in the customerRecords array.Executor is a void method that goes over all the records at customerRecords arrayand executes each record as explained below:• Each record has the format: Customer full name, Customer-id, followed by 3integer values that represent the detailed bill for the customer. As shown in thefollowing example: Ahmed Hesham, K15, 100,70,10• For each record, the Executor function reads the Customer full name, id, thenreadsthe three integer values and computes their summation, andaccumulates the results (i.e., the Customer full name, id, and the summationvalue) in the result data member.showResult is a void method that shows the result of records execution (which is storedin the result data member) to the user using JOptionPane message.toString is a method that returns the String "The customer informtation is: " + the stringthat is stored in result. Note: + means string concatenation.In the main:1. Read the records file name from user using JOptionPane input dialog. Give the filethis name: CustomerRecords.txt2. Read the records number from user using JOptionPane input dialog3. Create and instantiate an object of ParsingCustomerRecords class. Pass thefilename and records number to the constructor.4. Call Reader method5. Call Executor method6. Call showResult method7. Print the object that was created in step 2 (using a System.out.println statement).
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here