Given the Fruit class with the following data members attributes): Class name : Fruit Attributes I/fruit name :String name; String type; /Mlocal or imported double weight; I/in kg double price; l/price per kilogram Method : constructor, mutator, accessor, processor, printer a) Write the definition of the following methods: i. Default/Normal/Copy Constructor. ii. Mutator/Setter for each attribute. ii. Getter/Accessor/Retriever for each attribute. iv. A Processor method named isLocal () that returns true if it is local fruit or returns false otherwise. v. A processor method named calcTotalPrice () calculates and returns the total price of the fruit. In order to encourage the buyers to buy the local fruits, 3% discount is given on the total price. vi. Printer method named toString() to return the objects' information. b) Write an application program to do the following tasks: i. Declare an array of object named fruitList and store some data onto array. ii. Display the name of local fruits which has the highest price. iii. Calculate total sale of the imported fruits.

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

Java - OOP

1.2
Given the Fruit class with the following data members attributes):
Class name
:Fruit
Attributes
:String name;
/fruit name
/local or imported
String type;
double weight; |/in kg
double price;
//price per kilogram
Method
: constructor, mutator, accessor, processor, printer
a) Write the definition of the following methods:
i. Default/Normal/Copy Constructor.
ii. Mutator/Setter for each attribute.
iii. Getter/Accessor/Retriever for each attribute.
iv. A Processor method named isLocal () that returns true if it is local fruit
or returns false otherwise.
v. A processor method named calcTotalPrice() calculates and returns
the total price of the fruit. In order to encourage the buyers to buy the local
fruits, 3% discount is given on the total price.
vi. Printer method named toString() to return the objects' information.
b) Write an application program to do the following tasks:
i.
Declare an array of object named fruitList and store some data onto
array.
ii. Display the name of local fruits which has the highest price.
iii. Calculate total sale of the imported fruits.
Transcribed Image Text:1.2 Given the Fruit class with the following data members attributes): Class name :Fruit Attributes :String name; /fruit name /local or imported String type; double weight; |/in kg double price; //price per kilogram Method : constructor, mutator, accessor, processor, printer a) Write the definition of the following methods: i. Default/Normal/Copy Constructor. ii. Mutator/Setter for each attribute. iii. Getter/Accessor/Retriever for each attribute. iv. A Processor method named isLocal () that returns true if it is local fruit or returns false otherwise. v. A processor method named calcTotalPrice() calculates and returns the total price of the fruit. In order to encourage the buyers to buy the local fruits, 3% discount is given on the total price. vi. Printer method named toString() to return the objects' information. b) Write an application program to do the following tasks: i. Declare an array of object named fruitList and store some data onto array. ii. Display the name of local fruits which has the highest price. iii. Calculate total sale of the imported fruits.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

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