Jordan University of Science and Technology CS415 Contemporary Programming Techniques Midterm Exam – Second semester 2021 Name: 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 the following 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’ records are stored, and (2) the number of the records in the file. The constructor functionality is to assign suitable initial values to the fileName and recordsNumber data members. The constructor also should instantiate the customerRecords array, where the size of the array should be equal to recordsNumber. Reader is a void method that reads the Customers’ records file line by line and stores each 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 array and executes each record as explained below: • Each record has the format: Customer full name, Customer-id, followed by 3 integer values that represent the detailed bill for the customer. As shown in the following example: Ahmed Hesham, K15, 100,70,10 • For each record, the Executor function reads the Customer full name, id, then readsthe three integer values and computes their summation, and accumulates the results (i.e., the Customer full name, id, and the summation value) in the result data member. showResult is a void method that shows the result of records execution (which is stored in the result data member) to the user using JOptionPane message. toString is a method that returns the String "The customer informtation is: " + the string that 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 file this name: CustomerRecords.txt 2. Read the records number from user using JOptionPane input dialog 3. Create and instantiate an object of ParsingCustomerRecords class. Pass the filename and records number to the constructor. 4. Call Reader method 5. Call Executor method 6. Call showResult method 7. Print the object that was created in step 2 (using a System.out.println statement).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Jordan University of Science and Technology
CS415 Contemporary Programming Techniques
Midterm Exam – Second semester 2021
Name: 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 the
following 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’ records
are stored, and (2) the number of the records in the file. The constructor functionality is to
assign suitable initial values to the fileName and recordsNumber data members. The
constructor also should instantiate the customerRecords array, where the size of the array
should be equal to recordsNumber.
Reader is a void method that reads the Customers’ records file line by line and stores
each 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 array
and executes each record as explained below:
• Each record has the format: Customer full name, Customer-id, followed by 3
integer values that represent the detailed bill for the customer. As shown in the
following example: Ahmed Hesham, K15, 100,70,10
• For each record, the Executor function reads the Customer full name, id, then
readsthe three integer values and computes their summation, and
accumulates the results (i.e., the Customer full name, id, and the summation
value) in the result data member.
showResult is a void method that shows the result of records execution (which is stored
in the result data member) to the user using JOptionPane message.
toString is a method that returns the String "The customer informtation is: " + the string
that 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 file
this name: CustomerRecords.txt
2. Read the records number from user using JOptionPane input dialog
3. Create and instantiate an object of ParsingCustomerRecords class. Pass the
filename and records number to the constructor.
4. Call Reader method
5. Call Executor method
6. Call showResult method
7. Print the object that was created in step 2 (using a System.out.println statement).

Expert Solution
steps

Step by step

Solved in 4 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY