Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are writing an application for a resort that offers several activities to their guests, each for a fee ( above and beyond what the
You are writing an application for a resort that offers several activities to their guests,
each for a fee above and beyond what the guest is already paying for their room
For convenience, a guest is allowed to run an activity tab during their stay at the
resort; this means that the cost of each chosen activity is simply added to a running
total, and the guest will pay this total later when they check out of the resort
Write a Java class named ActivityTab that can be used to create & work with
ActivityTab objects. For each ActivityTab, we need to keep track of the name of the
guest who is running the tab eg "Holly Smith" their room number eg as well
as the current total amount owing which is always when the tab is first created
In the ActivityTab class, include three instance variables and one constructor. The
constructor should initialize the instance variables.
Provide three simple accessor methods: one to retrieve the guest's name, one to
retrieve their room number, and one to retrieve the current total amount owing.
Provide a mutator method that adds the price of an activity to the guest's activity
tab. The price of the activity is passed in through a parameter. Aside: You may
assume that all taxes are already included in the activity price.
Include one more accessor method that will calculate and return a tip amount when
given a percentage. For example, if the guest's current activity tab was and
they wanted to leave an tip, the tip amount would be This method will
accept the percentage as a parameter eg for and return the tip amount.
Part B
Write and test a ComputerScienceRetreat class. This class will serve as a driver
program for Part A and should be saved in the same folder directory as the
ActivityTab class.
In the main method of the ComputerScienceRetreat class, include statements to
support the following:
Annie Easley arrives first. She checks in to room number and opens an activity
tab. Create an ActivityTab object called anniesTab.
There is a block of free time before the first scheduled meeting at the CS retreat, so
Annie signs up for a half hour of lap swimming for
Alan Turing, who is staying in room then opens an activity tab; call this object
variable alansTab.
Alan chooses to take a cooking lesson, which costs
Clarence Ellis has checked into room and she is the next to open an activity
tab; call this object variable clarencesTab.
Clarence signs up for a group hike at a cost of followed by a yoga class for
Use two separate statements, one for each purchase.
Grace Hopper, from room also opens an activity tab; call this object variable
gracesTab.
Grace chooses a golf lesson, at a cost of
Later that evening, Grace and Clarence decide to take in a oneact play at the
resort's amphitheatre; the cost of this activity is per person.
Alan caps off the day by attending a wine tasting, at a cost of
Annie goes to a book reading in the resort's caf; this costs
Next, for each of the four ActivityTab objects print out the guest's name, room
number, and the amount owing.
Suppose Clarence wishes to leave an tip. Grace, feeling less generous, wishes to
leave a tip. Annie and Alan both opt to leave tips. Make the appropriate
method calls to retrieve the tip amounts for each guest. Print out these tip amounts.
Aside: You do NOT need to worry about displaying the tip amounts with exactly
decimal digits.
NOTE: In your driver, be sure to label all of your output so the meanings of the values
are clear. ie Don't just print out numbers without explaining what they represent.
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