Answered step by step
Verified Expert Solution
Link Copied!

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 (e.g. "Holly Smith"), their room number (e.g.125), as well
as the current total amount owing (which is always 0.00 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 22.50, and
they wanted to leave an 18% tip, the tip amount would be 4.05. This method will
accept the percentage as a parameter (e.g.0.18 for 18%) 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 73 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 4.50.
Alan Turing, who is staying in room 342, then opens an activity tab; call this object
variable alansTab.
Alan chooses to take a cooking lesson, which costs 9.75.
Clarence Ellis has checked into room 214, 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 6.00, followed by a yoga class for
8.75.(Use two separate statements, one for each purchase.)
Grace Hopper, from room 742, also opens an activity tab; call this object variable
gracesTab.
Grace chooses a golf lesson, at a cost of 9.75.
Later that evening, Grace and Clarence decide to take in a one-act play at the
resort's amphitheatre; the cost of this activity is 11.25 per person.
Alan caps off the day by attending a wine tasting, at a cost of 12.75.
Annie goes to a book reading in the resort's caf; this costs 7.80.
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 18% tip. Grace, feeling less generous, wishes to
leave a 15% tip. Annie and Alan both opt to leave 20% 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 2
decimal digits.)
NOTE: In your driver, be sure to label all of your output so the meanings of the values
are clear. (i.e. Don't just print out numbers without explaining what they represent.)

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago