Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!