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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
getter
setter
calculate Price
calculateChange()
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 getter setter calculate Price calculateChange() 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 5 steps with 3 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education