Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sophie and Sally are learning about money. Every once in a while, their parents will give them penny or shilling coins (no pounds at their

Sophie and Sally are learning about money. Every once in a while, their parents will give them penny or shilling coins (no pounds at their age!). They each keep their money in a special purse, and their parents may ask them how many pence or shillings coins they have. (Note we're not interested in the monetary values, just the number of coins. Thus someone might have 25 shilling coins or 20 penny coins.) The interaction between the girls' parents and Sophie and Sally is similar to the following:

Enter 1 for Sophie, 2 for Sally, or 0 to exit: 1 
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 1 
Enter the pence to give: 3 
Enter 1 for Sophie, 2 for Sally, or 0 to exit: 2 
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 2 
Enter the shillings to give: 2 
Enter 1 for Sophie, 2 for Sally, or 0 to exit: 2 
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 2 
Enter the shillings to give: 1 
Enter 1 for Sophie, 2 for Sally, or 0 to exit: 1 
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 3 
The purse has 3 pence, 0 shillings 
Enter 1 for Sophie, 2 for Sally, or 0 to exit: 2 
Enter 1 to give pence, 2 to give shillings, 3 to query her purse: 3 
The purse has 0 pence, 3 shillings 
Enter 1 for Sophie, 2 for Sally, or 0 to exit: 0 

Write a program to implement this scenario. Use two classes. One class should contain a main method and manage the dialog with the user. The other class should represent a Purse. The design of the Purse class is up to you. Make sure that your instance variables are private, follow the naming conventions, etc.

****DO NOT use switch/case. only use loops, arrays, classes, methods, etc but NO switch/case***

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. Check on your expectations:

Answered: 1 week ago