Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To Do: VACATION AND VACATIONDRIVER In this exercise, you will write a Java class for keeping track of sales for a company that sells vacation

To Do: VACATION AND VACATIONDRIVER

In this exercise, you will write a Java class for keeping track of sales for a company that sells vacation packages. Write the Vacation class with a vacation object being described by three instance variables: vacationName (a String), numSold (an integer that represents the number of those vacation packages sold), and priceEach (a double that is the price of the vacation package). I only want three instance variables!! The class should have the following methods:

A constructor that has two parameter a String containing the name of the vacation and a double containing its price. The constructor should set the other instance variable to zero.

An empty constructor

All getters and setters

A method updateSales() that takes a single integer parameter representing the number of additional vacations of that type sold. The method should add this number to the numSold instance variable and return nothing

A method totalValue() that takes no parameters and returns the total value of that vacation inventory

A toString() method that returns a string containing the name of the vacation and the number sold, the price each, and the total value

Write a VacationDriver program that uses Vacation objects to track the sales.

Ask the user for the number of different types of vacations and how many sales people are selling them.

Using a nested for loop, get the information for the vacations (see outline below). After each prompt, call the updateSales() method to update the number of vacations sold.

After all the data has been read in for a given type of vacation, call the toString() method for this to print out their information. Then loop to get the next vacation.

Here is an outline for you

public static void main(String[] args)

{

// ask for the number of vacations and read it into numVacations

// ask for the number of sales people and read it into numPeople

// beginning of loop for number of vacations

for(int i = 0; i < numVacations; i++)

{

//ask for the name and price and read these into variables

// create a Vacation instance using the data obtained above

for(int j = 0; j < numPeople; j++) // loop through the sales people {

// ask for the sales for the current vacation and read it in

// call updateSales with this number

} //end of inner loop

//print out this vacation info

} //end of outer for loop

} //end of main

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

Students also viewed these Databases questions

Question

Design a health and safety policy.

Answered: 1 week ago