Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java please. I need the code to read from text files. Objectives Use inheritance to create base and child classes Utilize multiple classes in

In java please. I need the code to read from text files.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Objectives Use inheritance to create base and child classes Utilize multiple classes in the same program. Perform standard input validation Implement a solution that uses polymorphism . Problem: Disneyland has begun a service that allows guests at the park to pre-order drinks and pick them up at a designated time so as to avoid long concession lines. Guests that spend more than $50 (cumulatively) become preferred customers and are awarded discounts on their orders. A program is needed to track the amount spent by each customer and promote them to preferred customer when they have accumulated $50 in purchases. Classes: Customer (base class) o Members First name (string) Last name (string) Guest ID (string) Amount spent (float) o Methods Overloaded Constructor Accessors Mutators Preferred Customer- Gold (derived from customer) . o Member Discount Percentage (float) o Methods "Overloaded Constructor (chained to base class constructor) Accessor Mutator . Preferred Customer Platinum (derived from customer) o Member Bonus bucks (float) o Methods "Overloaded Constructor (chained to base class constructor) Accessor Mutator Details The price of the drink is determined by the type of drink and the amount of ounces ordered o Soda - $0.20 o Tea $0.12 o Fruit punch $0.15 Each drink will come in a cylindrical container O Small Diameter-4 in " Height - 4.5 in - 12 oz. o Medium Diameter-4.5 in. Height-5.75 in. - 20 oz. o Large . Diameter-5.5 in " Height - 7 in. 32 Oz The container can be personalized with different Disney graphics o The total price of the personalization is determined by the price per square inch o The area covered by the graphic will be just the outer surface area of the cylinder o The surface area of the cylinder will not include the top and bottom of the cylinder . Preferred customer information and regular customer information will be stored in files and will be read into memory before the program processes orders. o The preferred customer file may be empty or may not exist. o In both cases, the respective customer array should not be created until a customer reaches preferred status .Regular customers and preferred customers will be held in 2 separate arrays. (-10 points if not) o Both gold and platinum customers will be stored in the same array (preferred) o Do not use an array list for this project The arrays will never be larger than the actual number of customers in each category Orders will be read from a file .After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold) o The preferred customer array will be resized to add one more element. .After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold) The preferred customer array will be resized to add one more element. Add the new preferred customer into the open element at the end of the preferred customer array Resize the regular customer array and remove the customer data that was promoted to preferred status o o o o Do not rearrange the order of the data in either array o Remember that each array should be no bigger than the number of customers at that level Gold preferred customers get a discount based on how much they have spent overall . $50 5% discount $100 : 10% discount $150-15% discount o This discount applies as soon as the above taret value is obtained Example 1: customer has spent $40 previously. The customer places an order for drinks that amounts to $10. The customer is immediately placed in preferred status and given a 5% discount. The new amount spent is $49.50 Example 2: customer has spent $90 previously. The customer places an order for drinks that amounts to $10. However, the customer has a 5% discount as a preferred customer The customer has a total of $99.50 after the discount is applied and is not moved to the next bracket for preferred customers If the customer placed an order for $11, the new total with the discount would be $100.45. The customer is immediately placed into the new bracket and a 10% discount is given instead. The new amount would be $99.90 and the customer would be at the 10% discount level . After processing an order, if a gold preferred customer has spent at least $200, promote the customer to platinum status . o Replace the gold member object in the array with a platinum member object o Update the bonus bucks if necessary (see below) Platinum preferred customers receive bonus bucks instead of a discount. . o For every $5 over $200, the customer receives 1 bonus buck (worth a dollar) When an order is placed, bonus bucks are only earned for every multiple of $5 above the beginning total For example, if a customer has spent $217, and makes a purchase of $12, the customer would earn 2 bonus bucks (one for $220 and one for $225) o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used If an order costs $5 and a bonus buck is used, the total sales increases by $4 Platinum status is applied when the total amount spent is $200 after gold member discounts are applied o o If the gold discount puts the customer under the $200 threshold, the customer remains at gold status Input: Input data will be stored in three files: preferred.dat, customers.dat and orders.dat. The total number of lines in each file will be unknown Preferred.dat will hold the data for preferred customers and customers.dat will hold the data for regular customers. Both files should be read at the beginning of the program to establish the preferred customer and regular customer arrays respectively. Prefed.dat may be empty or may not exist. In such cases, there should not be a preferred customer array created before reading the orders. Each line of preferred.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field There will be no invalid data on any line customer ID first name last name amount spent discount or bonus bucks e newline Amount spent will indicate if the customer is gold or platinum. Discount and bonus bucks will be an integer value The number will be followed by a percent sign if the customer is a gold member Each line of customer.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field There will be no invalid data on any line customer ID first name last name amount spent newline Orders.dat will hold all orders to process. Each valid line of the file will be formatted as follows (except for the last line of the file which may not have a newline character). A valid line will consist of data listed in the following order with a space between each field. There may be invalid data on any line. If a line contains invalid data, gnore everything on the line customer ID (string) size (character) - S, M, or L . drink type (string)soda, tea or punch square inch price (float) . quantity (integer) e newline Invalid data: Invalid data can consist of any of the following incorrect number of fields (more or less than 5) incorrect ID- doesn't match an existing ID of a customer incorrect value option for size or drink type garbage characters-character present in value that is outside the data type's acceptable character set o example: a letter character in a value for a field with a numeric data type Output: At the end of the program, write the regular customer data and preferred customer data to their respective files. Use the proper format as listed above in the Input section. There wil be no output to the screen. Objectives Use inheritance to create base and child classes Utilize multiple classes in the same program. Perform standard input validation Implement a solution that uses polymorphism . Problem: Disneyland has begun a service that allows guests at the park to pre-order drinks and pick them up at a designated time so as to avoid long concession lines. Guests that spend more than $50 (cumulatively) become preferred customers and are awarded discounts on their orders. A program is needed to track the amount spent by each customer and promote them to preferred customer when they have accumulated $50 in purchases. Classes: Customer (base class) o Members First name (string) Last name (string) Guest ID (string) Amount spent (float) o Methods Overloaded Constructor Accessors Mutators Preferred Customer- Gold (derived from customer) . o Member Discount Percentage (float) o Methods "Overloaded Constructor (chained to base class constructor) Accessor Mutator . Preferred Customer Platinum (derived from customer) o Member Bonus bucks (float) o Methods "Overloaded Constructor (chained to base class constructor) Accessor Mutator Details The price of the drink is determined by the type of drink and the amount of ounces ordered o Soda - $0.20 o Tea $0.12 o Fruit punch $0.15 Each drink will come in a cylindrical container O Small Diameter-4 in " Height - 4.5 in - 12 oz. o Medium Diameter-4.5 in. Height-5.75 in. - 20 oz. o Large . Diameter-5.5 in " Height - 7 in. 32 Oz The container can be personalized with different Disney graphics o The total price of the personalization is determined by the price per square inch o The area covered by the graphic will be just the outer surface area of the cylinder o The surface area of the cylinder will not include the top and bottom of the cylinder . Preferred customer information and regular customer information will be stored in files and will be read into memory before the program processes orders. o The preferred customer file may be empty or may not exist. o In both cases, the respective customer array should not be created until a customer reaches preferred status .Regular customers and preferred customers will be held in 2 separate arrays. (-10 points if not) o Both gold and platinum customers will be stored in the same array (preferred) o Do not use an array list for this project The arrays will never be larger than the actual number of customers in each category Orders will be read from a file .After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold) o The preferred customer array will be resized to add one more element. .After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold) The preferred customer array will be resized to add one more element. Add the new preferred customer into the open element at the end of the preferred customer array Resize the regular customer array and remove the customer data that was promoted to preferred status o o o o Do not rearrange the order of the data in either array o Remember that each array should be no bigger than the number of customers at that level Gold preferred customers get a discount based on how much they have spent overall . $50 5% discount $100 : 10% discount $150-15% discount o This discount applies as soon as the above taret value is obtained Example 1: customer has spent $40 previously. The customer places an order for drinks that amounts to $10. The customer is immediately placed in preferred status and given a 5% discount. The new amount spent is $49.50 Example 2: customer has spent $90 previously. The customer places an order for drinks that amounts to $10. However, the customer has a 5% discount as a preferred customer The customer has a total of $99.50 after the discount is applied and is not moved to the next bracket for preferred customers If the customer placed an order for $11, the new total with the discount would be $100.45. The customer is immediately placed into the new bracket and a 10% discount is given instead. The new amount would be $99.90 and the customer would be at the 10% discount level . After processing an order, if a gold preferred customer has spent at least $200, promote the customer to platinum status . o Replace the gold member object in the array with a platinum member object o Update the bonus bucks if necessary (see below) Platinum preferred customers receive bonus bucks instead of a discount. . o For every $5 over $200, the customer receives 1 bonus buck (worth a dollar) When an order is placed, bonus bucks are only earned for every multiple of $5 above the beginning total For example, if a customer has spent $217, and makes a purchase of $12, the customer would earn 2 bonus bucks (one for $220 and one for $225) o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used If an order costs $5 and a bonus buck is used, the total sales increases by $4 Platinum status is applied when the total amount spent is $200 after gold member discounts are applied o o If the gold discount puts the customer under the $200 threshold, the customer remains at gold status Input: Input data will be stored in three files: preferred.dat, customers.dat and orders.dat. The total number of lines in each file will be unknown Preferred.dat will hold the data for preferred customers and customers.dat will hold the data for regular customers. Both files should be read at the beginning of the program to establish the preferred customer and regular customer arrays respectively. Prefed.dat may be empty or may not exist. In such cases, there should not be a preferred customer array created before reading the orders. Each line of preferred.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field There will be no invalid data on any line customer ID first name last name amount spent discount or bonus bucks e newline Amount spent will indicate if the customer is gold or platinum. Discount and bonus bucks will be an integer value The number will be followed by a percent sign if the customer is a gold member Each line of customer.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field There will be no invalid data on any line customer ID first name last name amount spent newline Orders.dat will hold all orders to process. Each valid line of the file will be formatted as follows (except for the last line of the file which may not have a newline character). A valid line will consist of data listed in the following order with a space between each field. There may be invalid data on any line. If a line contains invalid data, gnore everything on the line customer ID (string) size (character) - S, M, or L . drink type (string)soda, tea or punch square inch price (float) . quantity (integer) e newline Invalid data: Invalid data can consist of any of the following incorrect number of fields (more or less than 5) incorrect ID- doesn't match an existing ID of a customer incorrect value option for size or drink type garbage characters-character present in value that is outside the data type's acceptable character set o example: a letter character in a value for a field with a numeric data type Output: At the end of the program, write the regular customer data and preferred customer data to their respective files. Use the proper format as listed above in the Input section. There wil be no output to the screen

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions