Write a java program that performs the following: Create class named Customer that contains the following:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a java program that performs the following: Create class named Customer that contains the following: Two private non-static data members: name: represents the name of the customer and its type is String. category: represent the category of the customer and its type is integer. There are three categories: 1 for first class customers, 2 for second class customers, and 3 for third class customers. Member methods as follows: Default constructor: initializes the name to "no name" and the category to 3. Parametrized constructor: receives two values for the name and category. Then, it initializes the received values in the name and category data members respectively. setName method: that receives a string value and sets the received value in the name data member. setCategory method: that receives an integer and sets the received value in the category data member. getName method: that returns the name of the customer. getCategory method: that returns the category of the customer. getDiscount method: that returns the discount given to customer. 30% discount is given to customers of category 1, 20% discount is given to customers of category 2, and 10% discount is given to customers of category 3. getStars method: that returns the number of stars given to customer. The number of stars depends on customer category. 3 stars (***) are given to customers of category 1, 2 stars (**) are given to customers of category 2, and 1 star (*) is given to customers of category 3. toString overridden method: that returns the following data: customer name, customer category, number of stars, and discount value. Create class named Invoice that contains the following: Three private non-static data members: invoiceID: represents the id of the invoice and its type is integer. The value of invoiceID is assigned the current value of the autoGenerated InvoiceID. customer: represents the customer of the invoice and its type is Customer. amount: represents the amount of the invoice before discount and its type is double. One private static data member: autoGenerated InvoiceID: represents the auto-generated id of the invoice of type integer which is initialized to 0. For each time invoice object is created, autoGenerated InvoiceID value is incremented automatically by 1 and the result is assigned to invoiceID. Member methods as follows: Default constructor: initializes the customer with the default constructor of the Customer class and the amount to 0.0. Parametrized constructor: receives 2 values for customer object and amount. Then, it initializes the customer object using the received object and the received amount value in the amount data member. setCustomer method: that receives an object of type Customer and sets its value in the customer object. set Amount method: that receives a double value and sets the received value in the amount data member. getCustomer method: that returns the customer object of the invoice. getAmount method: that returns the amount of the invoice. getAmount AfterDiscount method: that returns the amount of the invoice after discount. toString overridden method: that returns the data members of the class in the following way: invoice id, customer name, customer category, number of stars, discount value, amount of the invoice, amount of the invoice after discount. [Please, see sample output at end of page]. Create class named Demo that contains the main method. In the main method do the following: Create an array of 4 objects of type Customer. Ask the user to enter the values of the customer name and category. Fill the array with this data by using the parametrized constructor. Create an array of 4 objects of type Invoice. Ask the user to enter the value of the invoice amount. Fill the array with this data by using the parametrized constructor. Input data: System.out.print ("Enter customer name: "); string name = input.next(); System.out.print ("Enter amount: "); double amount = input.nextDouble(); System.out.print ("Enter customer category: "); int category = input.nextInt(); Change the name of the third customer to "Rami". Change the category of the first customer to 2. Change the amount value of the last invoice to 400. Print data of all invoices. I.e., invoice id, customer name, customer category, number of stars, discount value, amount of the invoice, amount of the invoice after discount. [Hint: you need to call to String method of Invoice class]. A sample output may look like this: Sample Output: Invoice-Id Customer-Name Category Stars Discount ----- Amount ----- Amount-After-Discount 1 Hikmat 2 ** 0.2 2 Talal 1 *** 0.3 100.0 200.0 140.0 80.0 3 Rami 2 ** 0.2 300.0 240.0 4 Ali 3 * 0.1 400.0 360.0 Write a java program that performs the following: Create class named Customer that contains the following: Two private non-static data members: name: represents the name of the customer and its type is String. category: represent the category of the customer and its type is integer. There are three categories: 1 for first class customers, 2 for second class customers, and 3 for third class customers. Member methods as follows: Default constructor: initializes the name to "no name" and the category to 3. Parametrized constructor: receives two values for the name and category. Then, it initializes the received values in the name and category data members respectively. setName method: that receives a string value and sets the received value in the name data member. setCategory method: that receives an integer and sets the received value in the category data member. getName method: that returns the name of the customer. getCategory method: that returns the category of the customer. getDiscount method: that returns the discount given to customer. 30% discount is given to customers of category 1, 20% discount is given to customers of category 2, and 10% discount is given to customers of category 3. getStars method: that returns the number of stars given to customer. The number of stars depends on customer category. 3 stars (***) are given to customers of category 1, 2 stars (**) are given to customers of category 2, and 1 star (*) is given to customers of category 3. toString overridden method: that returns the following data: customer name, customer category, number of stars, and discount value. Create class named Invoice that contains the following: Three private non-static data members: invoiceID: represents the id of the invoice and its type is integer. The value of invoiceID is assigned the current value of the autoGenerated InvoiceID. customer: represents the customer of the invoice and its type is Customer. amount: represents the amount of the invoice before discount and its type is double. One private static data member: autoGenerated InvoiceID: represents the auto-generated id of the invoice of type integer which is initialized to 0. For each time invoice object is created, autoGenerated InvoiceID value is incremented automatically by 1 and the result is assigned to invoiceID. Member methods as follows: Default constructor: initializes the customer with the default constructor of the Customer class and the amount to 0.0. Parametrized constructor: receives 2 values for customer object and amount. Then, it initializes the customer object using the received object and the received amount value in the amount data member. setCustomer method: that receives an object of type Customer and sets its value in the customer object. set Amount method: that receives a double value and sets the received value in the amount data member. getCustomer method: that returns the customer object of the invoice. getAmount method: that returns the amount of the invoice. getAmount AfterDiscount method: that returns the amount of the invoice after discount. toString overridden method: that returns the data members of the class in the following way: invoice id, customer name, customer category, number of stars, discount value, amount of the invoice, amount of the invoice after discount. [Please, see sample output at end of page]. Create class named Demo that contains the main method. In the main method do the following: Create an array of 4 objects of type Customer. Ask the user to enter the values of the customer name and category. Fill the array with this data by using the parametrized constructor. Create an array of 4 objects of type Invoice. Ask the user to enter the value of the invoice amount. Fill the array with this data by using the parametrized constructor. Input data: System.out.print ("Enter customer name: "); string name = input.next(); System.out.print ("Enter amount: "); double amount = input.nextDouble(); System.out.print ("Enter customer category: "); int category = input.nextInt(); Change the name of the third customer to "Rami". Change the category of the first customer to 2. Change the amount value of the last invoice to 400. Print data of all invoices. I.e., invoice id, customer name, customer category, number of stars, discount value, amount of the invoice, amount of the invoice after discount. [Hint: you need to call to String method of Invoice class]. A sample output may look like this: Sample Output: Invoice-Id Customer-Name Category Stars Discount ----- Amount ----- Amount-After-Discount 1 Hikmat 2 ** 0.2 2 Talal 1 *** 0.3 100.0 200.0 140.0 80.0 3 Rami 2 ** 0.2 300.0 240.0 4 Ali 3 * 0.1 400.0 360.0
Expert Answer:
Related Book For
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell
Posted Date:
Students also viewed these programming questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Go to the 2013 annual report for Kelloggs Company at http://investor.kelloggs.com/investor-relations/annual-reports. What is the cost of finished goods inventory for 2013 as shown in note 17?
-
Janell starts 10 m from a motion sensor and walks at 2 m/s toward the sensor. When she is 3 m from the sensor, she stantly turns around and walks at the same speed back to the starting point. a....
-
Using the Internet, find an article about costs. List and define as many different types of costs from the article as you can.
-
Suppose that when you lie on your bed, your body is supported by 30 of the springs in the mattress. Assuming that all the springs are identical and that your body presses on each spring equally,...
-
The adjusted trial balance for Okabe Company is presented in exercise. In Exercise, Okabe Company ended its fiscal year on July 31, 2017. The companys adjusted trial balance as of the end of its...
-
The frequency distribution of the ages of the employees of Stark Tech is given below: 5-6=288= Age 50-54 45-49 40-44 35-39 30-34 25-29 20-24 1. Find the following: a. mean b. median c. mode of this...
-
A reason for the lack of consistency in consolidation policy is Blank______. the equity method of accounting the cost method of financing forming of partnerships off-balance-sheet financing
-
Jian and Chen are each considering purchasing a certain stock at a price of \( 135\) per share. They have the same financial analyst, and according to her, there is a \(60 \%\) probability that the...
-
Use a decision tree to illustrate how a risk-neutral plaintiff in a lawsuit decides whether to settle a claim or go to trial. The defendants offer \( 60,000\) to settle. If the plaintiff does not...
-
Unfortunately, oil spills are not uncommon. For example, in August 2016, two tankers ran into each other off the coast of Japan, causing an oil spill. In January 2017, two different tankers ran into...
-
Assume the role of Nick and write a bad-news announcement to all employees explaining the elimination of the tuition-reimbursement program. Explain that the company has lost money in three of the...
-
Assume the role of Nick and write a bad-news announcement to all former Elite Customers explaining the elimination of the program. Juan Hernandez for many years had worked with Jensen Chemicals to...
-
The budgeted production of UNIX Inc. is 8,000 units. Each unit requires 40 minutes of direct labor work to complete. The direct labor rate is $100 per hour. Calculate the budgeted cost of direct...
-
Tanaka Company's cost and production data for two recent months included the following: March April Production (units).........300................600 Rent.....................$1,800............$1,800...
-
What minimum information must be extracted from a video clip of a moving object in order to quantify the object's motion?
-
The sequence in Figure P2.3 represents a ball that is initially held above the ground. In the first frame the ball is released. In subsequent frames the ball falls, bounces on the ground, rises, and...
-
Figure P2.4 shows a graph of position versus frame number from a video clip of a moving object. Describe this motion from beginning to end, and state any assumptions you make. Data from Figure P2.4...
Study smarter with the SolutionInn App