Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Review Chapter 9 and Chapter 9 examples. Build an application that handles setti

ID: 3881434 • Letter: R

Question

Review Chapter 9 and Chapter 9 examples.

Build an application that handles setting up vacation plans.

Create a superclass called VacationInstance Variables

destination - String

budget - double

Constructors - default and parameterized to set all instance variables

Access and mutator methods

budgetBalance method - returns the amount the vacation is under or over budget. Under budget is a positive number and over budget is a negative number. This method will be overwritten in the subclass so have it return Java's integer minimum value.

Create a concrete class called AllInclusive that represents an all inclusive vacation like Sandals or Club Med.Instance Variables

brand - String, such as Sandels , Club Med etc

rating - int, representing number of stars such as 5 star rating.

price - double, the total cost of the vacation

Constructor - default and parameterized to set all instance variables

Accessor and mutator methods

Overwritten budgetBalance method.

Create a concrete class called ALaCarte - a pay for each activity separately

Instance Variables

hotelName - String

roomCost - double

airline - String

airfare - double

meals - double - estimated total meal expenses.

Constructor - default and parameterized to set all instance variables

Accessor and mutator methods

Overwritten budgetBalance method.

Create a VacationTester class

Test all methods of both classes, however test methods in the superclass Vacation from either subclass object (AllInclusive or ALaCarte)

Polymorphically call the budgetBalance method by creating at least 2 object of each Vacation subclass, and place those object in a collection of the Vacation object.

Explanation / Answer

/* package codechef; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Vacationinstance

{

public Vacationinstance(){

String destination = "";

double budget = 10000;

}

void setdata(String destination,double budget)

{

destination = destination;

budget = budget;

}

double budgetbalance(double a)

{

if(10000>a)

{

return 1;

}

else{

return -1;

}

}

  

}

class Alllnclusive

{

  

int h;

public Alllnclusive(){

String brand;

int rating;

double price = 10000;

}

void setdata(String brand,int rating,double price)

{

brand = brand;

rating = rating;

price = price;

}

void budgetbalance(double a)

{

if(10000>a)

{

System.out.println("under budget");

}

else

{

System.out.println("over budget");

}

}

  

}

class Alacarte

{

public Alacarte(){

String hotelname;

double roomcost;

String airline;

double airfare;

double meals;

  

}

void setdata(String hotelname,double roomcost,String airline,double airfare,double meals)

{

hotelname = hotelname;

roomcost = roomcost;

airline = airline;

airfare = airfare;

meals = meals;

}

  

void budgetbalance(double roomcost,double airfare,double meals)

{

double total;

total = roomcost+airfare+meals;

System.out.println("total fare is "+total);

  

}

}

class Vacationtester

{

public static void main (String[] args) throws java.lang.Exception

{

// your code goes here

Vacationinstance v = new Vacationinstance();

Alllnclusive a1 = new Alllnclusive();

Alacarte a2 = new Alacarte();

Scanner sc = new Scanner(System.in);

System.out.println("enter the destination");

String a = sc.next();

System.out.println("enter the budget quoted by you");

double b = sc.nextDouble();

v.setdata(a,b);

double c = v.budgetbalance(b);

if(c<0)

{

System.out.println("over budget");

}

else{

System.out.println("under budget");

}

System.out.println("enter the brand");

String d = sc.nextLine();

System.out.println("enter the total cost of voaction");

double e = sc.nextDouble();

System.out.println("Enter the rating out of 5");

int f = sc.nextInt();

a1.setdata(d,f,e);

a1.budgetbalance(e);

System.out.println("enter the airline");

String g = sc.nextLine();

System.out.println("enter the hotelname");

String h = sc.nextLine();

System.out.println("enter the room cost");

double i = sc.nextDouble();

System.out.println("enter the airfare");

double j = sc.nextDouble();

System.out.println("enter the meals rate");

double k = sc.nextDouble();

a2.setdata(h,i,g,j,k);

a2.budgetbalance(i,j,k);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote