NEED HELP IN JAVA PROGRAMMING. "ENCAPSULATION" SHOULD BE IMPLEMENTED IN THE CODE. PLEASE FOLLOW INSTRUCTIONS AND REFER TO THE PICTURE BELOW FOR THE SAMPLE OUTPUT AND EXPLANATION. "ENCAPSULATION" Instructions 1. Create a program that will simulate a mango store. 2. First create the class Fruit see the representation of the class. 3. Second create the class FruitTester see the representation of the class. 4. You will not ask the user to enter the name, price and color of the fruit. Give them a static value using mutator methods. 5. Aside from the accessor and mutator, create a user defined method name calculatePrice( ) that will calculate the total price the user needs to pay. Formula (quantity * price). 6. Also create a user defined method name calculateChange( ) that will calculate the change of the user. Formula (cash - totalPrice). Note: You can create a validation that if the cash entered by the user is lower than the totalPrice. 7. When printing the values invoke the accessor methods and the user-defined methods.

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
NEED HELP IN JAVA PROGRAMMING. "ENCAPSULATION" SHOULD BE IMPLEMENTED IN THE CODE. PLEASE FOLLOW INSTRUCTIONS AND REFER TO THE PICTURE BELOW FOR THE SAMPLE OUTPUT AND EXPLANATION. "ENCAPSULATION" Instructions 1. Create a program that will simulate a mango store. 2. First create the class Fruit see the representation of the class. 3. Second create the class FruitTester see the representation of the class. 4. You will not ask the user to enter the name, price and color of the fruit. Give them a static value using mutator methods. 5. Aside from the accessor and mutator, create a user defined method name calculatePrice( ) that will calculate the total price the user needs to pay. Formula (quantity * price). 6. Also create a user defined method name calculateChange( ) that will calculate the change of the user. Formula (cash - totalPrice). Note: You can create a validation that if the cash entered by the user is lower than the totalPrice. 7. When printing the values invoke the accessor methods and the user-defined methods.
Fruit
name
price
color
gener
setter
calculatPrice
Sample output 1.
Welcome to my Mango Store!
Mango price is 38.50 per price
Enter customer name: Rowie
Enter quantity: 5
Enter cash: 200
Thank you for buying!
You bought 5 mangoes for 192.50
Your change is 7.50
class
instance variables
accessor methods
mutator methods
user defined methods
name
price
Color
Fruit Tester
//name of fruit
//price of fruit
//color of fruit
customerName
quantity
cash
main method)
Sample output 2.
Welcome to my Mango Store!
Mango price is 38.50 per price
Enter customer name: Aki
Enter quantity: 9
Enter cash: 500
Thank you for buying!
You bought 9 mangoes for 346.50
Your change is 153.50
class
local variables
[]
Transcribed Image Text:Fruit name price color gener setter calculatPrice Sample output 1. Welcome to my Mango Store! Mango price is 38.50 per price Enter customer name: Rowie Enter quantity: 5 Enter cash: 200 Thank you for buying! You bought 5 mangoes for 192.50 Your change is 7.50 class instance variables accessor methods mutator methods user defined methods name price Color Fruit Tester //name of fruit //price of fruit //color of fruit customerName quantity cash main method) Sample output 2. Welcome to my Mango Store! Mango price is 38.50 per price Enter customer name: Aki Enter quantity: 9 Enter cash: 500 Thank you for buying! You bought 9 mangoes for 346.50 Your change is 153.50 class local variables []
Expert Solution
steps

Step by step

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