Currently, you have a RunCustomer class that reads customer data from a file, creates a Customer object, and writes form

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Currently, you have a RunCustomer class that reads customer data from a file, creates a Customer object, and writes form

Post by answerhappygod »

Currently You Have A Runcustomer Class That Reads Customer Data From A File Creates A Customer Object And Writes Form 1
Currently You Have A Runcustomer Class That Reads Customer Data From A File Creates A Customer Object And Writes Form 1 (160.96 KiB) Viewed 32 times
Currently, you have a RunCustomer class that reads customer data from a file, creates a Customer object, and writes formatted output to standard output. In this project, you will create an additional field in your Customer class along with an accessor and mutator for the field and a method to display the Customer data. In RunCustomer, you will create an array of Customer objects, you will create a method to print customer data and this method will be called from the main method. Customer class Add a data field to your customer class called orderTotal. This field should be a double. Methods Create an accessor and mutator method for the new order total field Add a display() method that takes no parameters and does not return a value. This method should display a customer's name, ID number, phone number, order total, discount, total after discount. (Code that displays customer data is currently in RunCustomer within the while loop. Remove that code from RunCustomer and add it to this method. It will be very similar with perhaps a few tweaks. The output will look the same as the previous project. Since the code for determining the customer's discount is also within the loop, that will be moved to the display method as well.)
RunCustomer class Create an array of type Customer. We need to give the array a size. Although we may not know the number of customers in the file, we are going to fudge it a little here and give the array a size of 8. There are 8 customers in the file. Normally, we might not know this. This class currently opens a file for reading, and then iterates through the file reading each customer's data and writing customer data to standard output. The loop ends when there is no more data in the file. It currently creates the Customer object and calls a 4-argument constructor. After you create the Customer object, add the customer's order total to the object by calling the order total mutator (set) method you created in the Customer class. After the Customer object has been created and updated with the order total, add the Customer object to the array. You will need an index to add the Customer object to the array. To do this, create an int variable that is set to o before the loop begins and incremented within the loop. Remove all the output statements. After the loop completes, you will have an array of type Customer that will be filled with 8 Customer objects. After the loop, call the printCustomers() method and send the Customer array to this method.
printCustomers() In the RunCustomer class, after the main method, create a method called printCustomers() that defines one parameter of type Customer array. In this method, iterate through the array and output the contents of each customer in the array by calling the display method in the Customer class. Notes: You are creating ONE array. The type of the array is Customer. You are NOT creating an ArrayList
CK901 Daniel LaRusso 5189999999 B 51.20 CK581 Johnny Lawrence 5188888888 с 103.59 CK109 Miguel Diaz 5185555555 A 24.99 CK318 Samantha LaRusso 5182222222 D 59.89 CK223 Robby Keene 5181111111 с 20.88 CK712 Eli Moskowitz 5184444444 A 15.44 CK860 Tory Nichols 5183333333 B 202.11 CK554 John Kreese 5187777777 D 33.12
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply