Answered step by step
Verified Expert Solution
Question
1 Approved Answer
WNNrite a class called Purse. Purse should have the following: three int instance variables: pounds, shillings and pence. a no argument constructor ( i .
WNNrite a class called Purse. Purse should have the following: three int instance variables: pounds, shillings and pence. a no argument constructor ie Purse that initializes the instance variables to
a mutator method void addPoundsint poundsToAdd
a mutator method void addShillingsint shillingsToAdd You may assume shillingsToAdd is less than
Note that if addShillings increases the number of shillings to or more, the pounds value should be increased until shillings is less than
a mutator method void addPenceint penceToAdd You may assume penceToAdd is less than Note that if addPence increases the number of pence to or more, the shillings value should be increased until pence is less than
an accessor method int getPounds that returns the number of pounds in the purse an accessor method int getShillings that returns the number of shillings in the purse.
an accessor method int getPence that returns the number of pence in the purse.
a mutator method void spendint poundsToRemove, int shillingsToRemove, int penceToRemove that removes the specified amount of money from the purse. You may assume the purse has sufficient total funds to cover the withdrawal, though you may have to break a pound into shillings, or a shilling into pence.
an accessor method String toString that returns a String representation of the purse such as "pounds shillings pence
Create : A tester class, PurseTester, is attached for your use. PurseTester has only a single main method, and does the following: creates two Purse objects, sophie and sally has a loop whose body executes two times.
For each execution of the loop, it asks the user for the pounds, shillings and pence sophie and sally each should add to their purses ;displays the amount of money in each purse; asks the user for the pounds, shillings and pence sophie and sally each should spend; displays the amount of money in each purse
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started