Exercise 1. (60 pts) Implement the class Product as presented by the following UML diagram: Product code double type: char price : double Producti) getters/setters getfinalPrice) double setNewCode() : void printProduct) void type attribute: M for meat, F for fruit, V for vegetables getFinalPrice(): return the final price which is equal to price - price "0.3 setNewCode(): the New code is the initial code concatenated (using + operator) with the underscore symbol and with the type attribute. Example: if the code is 23 and the type is M then the new code will be 23_M Exercise 2. (40 pts) Write a class to test the Product class as follows: a. Create a product object Prodi by reading its code, type and price from the user. (10 pts) b. Set the user inputs to the attributes of Prodl created. (10 pts) c. Change its code with a new one using the setNewCode) method explained above. (5 pts) d. Find the final price of Prodl. (5 pts) e. Print the details of Prodl (new code, type, final price). (10 pts) a. For the type you should display the whole name, for example if the type is F then we display Fruit

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
H*
O N 67 1 11:27
+961 71 947 949
18 minutes ago
LEBANESE
INTERNATIONAL
LIU
UNIVERSITY
CSCI 300L – Intermediate Programming with Objects Lab
Exam I
Duration: 60 minutes
Exercise 1. (60 pts) Implement the class Product as presented by the following UML diagram:
Product
code double
type : char
price : double
Product)
getters/setters)
getFinalPrice(): double
+setNewCode() : voidi
printProduct() : void
type attribute: M for meat, F for fruit, V for vegetables
getFinalPrice(): return the final price which is equal to price - price * 0.3
setNewCode(): the New code is the initial code concatenated (using + operator) with the
underscore symbol and with the type attribute. Example: if the code is 23 and the type is
M then the new code will be 23_M
Exercise 2. (40 pts) Write a class to test the Product class as follows
a. Create a product object Prod1 by reading its code, type and price from the user. (10 pts)
b. Set the user inputs to the attributes of Prodl created. (10 pts)
c. Change its code with a new one using the setNewCode() method explained above. (5 pts)
d. Find the final price of Prodl. (5 pts)
e. Print the details of Prodl (new code, type, final price). (10 pts)
a. For the type you should display the whole name, for example if the type is F then
we display Fruit
Sample Run:
Enter the produet code: 65
Enter the product type: 7
Enter the product price: 43
New code is 65_7
Details of the product are: code - 65 F; type- Fruit; final price- 30.1
Transcribed Image Text:H* O N 67 1 11:27 +961 71 947 949 18 minutes ago LEBANESE INTERNATIONAL LIU UNIVERSITY CSCI 300L – Intermediate Programming with Objects Lab Exam I Duration: 60 minutes Exercise 1. (60 pts) Implement the class Product as presented by the following UML diagram: Product code double type : char price : double Product) getters/setters) getFinalPrice(): double +setNewCode() : voidi printProduct() : void type attribute: M for meat, F for fruit, V for vegetables getFinalPrice(): return the final price which is equal to price - price * 0.3 setNewCode(): the New code is the initial code concatenated (using + operator) with the underscore symbol and with the type attribute. Example: if the code is 23 and the type is M then the new code will be 23_M Exercise 2. (40 pts) Write a class to test the Product class as follows a. Create a product object Prod1 by reading its code, type and price from the user. (10 pts) b. Set the user inputs to the attributes of Prodl created. (10 pts) c. Change its code with a new one using the setNewCode() method explained above. (5 pts) d. Find the final price of Prodl. (5 pts) e. Print the details of Prodl (new code, type, final price). (10 pts) a. For the type you should display the whole name, for example if the type is F then we display Fruit Sample Run: Enter the produet code: 65 Enter the product type: 7 Enter the product price: 43 New code is 65_7 Details of the product are: code - 65 F; type- Fruit; final price- 30.1
Expert Solution
steps

Step by step

Solved in 2 steps with 1 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