Question

COVERT TO PSEUDOCODE /****************************Vacation.java*****************************/ public abstract class Vacation {    /*    * private data field...

COVERT TO PSEUDOCODE

/****************************Vacation.java*****************************/


public abstract class Vacation {

   /*
   * private data field
   */
   private double cost;
   private double budget;
   private String destination;

   /**
   *
   * @param cost
   * @param budget
   * @param destination
   */
   public Vacation(double cost, double budget, String destination) {
       super();
       this.cost = cost;
       this.budget = budget;
       this.destination = destination;
   }

   //getter and setter
   public double getCost() {
       return cost;
   }

   public void setCost(double cost) {
       this.cost = cost;
   }

   public double getBudget() {
       return budget;
   }

   public void setBudget(double budget) {
       this.budget = budget;
   }

   public String getDestination() {
       return destination;
   }

   public void setDestination(String destination) {
       this.destination = destination;
   }

   public abstract double keptToBudget();

   @Override
   public String toString() {
       return "Vacation [cost=" + cost + ", budget=" + budget + ", destination=" + destination;
   }
  
  
}
/*************************************AllInclusiveVacation.java*******************************/


public class AllInclusiveVacation extends Vacation {

   /*
   * private data field
   */
   private String brand;
   private double rating;
   private double totalCost;

   /**
   *
   * @param cost
   * @param budget
   * @param destination
   */
   public AllInclusiveVacation(double cost, double budget, String destination) {
       super(cost, budget, destination);
   }

   /**
   *
   * @param cost
   * @param budget
   * @param destination
   * @param brand
   * @param rating
   * @param totalCost
   */
   public AllInclusiveVacation(double cost, double budget, String destination, String brand, double rating,
           double totalCost) {
       super(cost, budget, destination);
       this.brand = brand;
       this.rating = rating;
       this.totalCost = totalCost;
   }

   //getter and setter
   public String getBrand() {
       return brand;
   }

   public void setBrand(String brand) {
       this.brand = brand;
   }

   public double getRating() {
       return rating;
   }

   public void setRating(double rating) {
       this.rating = rating;
   }

   public double getTotalCost() {
       return totalCost;
   }

   public void setTotalCost(double totalCost) {
       this.totalCost = totalCost;
   }

   @Override
   public double keptToBudget() {

       double balance = getBudget() - totalCost;

       return balance;
   }

   @Override
   public String toString() {
       return super.toString()+", brand=" + brand + ", rating=" + rating + ", totalCost=" + totalCost + "]";
   }

  
}
/*************************************PiecemealVacation.java*******************************/

import java.util.Arrays;

public class PiecemealVacation extends Vacation {

   /*
   * private data field
   */
   private String[] expenses;
   private double[] expensesCost;

   /**
   *
   * @param cost
   * @param budget
   * @param destination
   * @param expenses
   * @param expensesCost
   */
   public PiecemealVacation(double cost, double budget, String destination, String[] expenses, double[] expensesCost) {
       super(cost, budget, destination);
       this.expenses = expenses;
       this.expensesCost = expensesCost;
   }

   public String[] getExpenses() {
       return expenses;
   }

   public void setExpenses(String[] expenses) {
       this.expenses = expenses;
   }

   public double[] getExpensesCost() {
       return expensesCost;
   }
  
   public void setExpensesCost(double[] expensesCost) {
       this.expensesCost = expensesCost;
   }

   @Override
   public double keptToBudget() {

       double totalExpensesCost = 0;
       for (double d : expensesCost) {

           totalExpensesCost += d;
       }

       return getBudget() - totalExpensesCost;
   }

   @Override
   public String toString() {
       return super.toString()+", expenses=" + Arrays.toString(expenses) + ", expensesCost="
               + Arrays.toString(expensesCost) + "]";
   }

  
}
/***********************TestVacation.java********************************/


public class TestVacation {

   public static void main(String[] args) {

       //create different type of object
       AllInclusiveVacation allInclusiveVacation = new AllInclusiveVacation(1000, 1500, "Jaipur", "ClubMed", 5.0, 900);
       AllInclusiveVacation allInclusiveVacation2 = new AllInclusiveVacation(500, 1000, "SWM", "Delta Vacation", 5.0,
               800);

       PiecemealVacation piecemealVacation = new PiecemealVacation(1000, 2000, "Udaipur",
               new String[] { "Hotel", "Meal", "Taxi" }, new double[] { 500.0, 600.0, 400.0 });
       PiecemealVacation piecemealVacation2 = new PiecemealVacation(1000, 2000, "Udaipur",
               new String[] { "Hotel", "Meal", "Taxi" }, new double[] { 1000.0, 700.0, 400.0 });

       Vacation vacation = new AllInclusiveVacation(1000, 1500, "Jaipur", "ClubMed", 5.0, 900);
       Vacation vacation2 = new PiecemealVacation(1000, 2000, "Udaipur", new String[] { "Hotel", "Meal", "Taxi" },
               new double[] { 500.0, 600.0, 400.0 });

       Vacation[] vacations = new Vacation[6];

       //adding into the array
       vacations[0] = allInclusiveVacation;
       vacations[1] = allInclusiveVacation2;
       vacations[2] = piecemealVacation;
       vacations[3] = piecemealVacation2;
       vacations[4] = vacation;
       vacations[5] = vacation2;

       //print the information
       for (Vacation vacation3 : vacations) {

           if (vacation3.keptToBudget() > 0) {

               System.out.println(vacation3.toString() + " And its under budget of " + vacation3.keptToBudget());
           } else {

               System.out.println(vacation3.toString() + " And its over budget of " + vacation3.keptToBudget());
           }
       }

   }
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Declare Class Vacation

BEGIN

Declare cost as double

Declare budget as double

Declare destination as String

Vacation(C,B,D)

begin

cost = C;

budget = B;

destination = D;

end

getCost()

return cost;

get budget()

return budget;

getDestination()

return destination;

abstract keptToBudget();

toString()

return cost+" "+budget+" "+destination;

END

Declare class AllInclusiveVacation extends Vacation

BEGIN

Declare brand as String
Declare rating as double
Declare totalCost as double

AllInclusiveVacation(B,R,TC)

begin

brand = B;

rating = R;

totalCost = TC;

end

getRating()

return rating;

getBrand()

return brand;

getTotalCost()

return totalCost;

  keptToBudget()

return budget - totalCost;

toString() : String

return super.toString() + brand + " "+ rating+ " "+totalCost;

END

Declare class PiecemealVacation extends Vacation

BEGIN

Declare expenses : String[ ]

Declare expensesCost : double[ ]

  PiecemealVacation( exp, expCost)

begin

expenses = exp;

expensesCost = expCost;

end

getExpenses() : String[]

return expenses;

getExpensesCost() : double[]

return expensesCost;

keptToBudget()

begin

Declare totalCost = 0

for each expensesCost

totalCost = totalCost+expensesCost;

return budget - totalCost;

end

toString() : String

return super.toString() + expenses[ ]+ " "+ expensesCost[ ] + " "+keptToBudget();

END

Declare class TestVacation

BEGIN

main()

begin

Decalre vacations : Vacation[ ]

fill array vacation by creating different type of vacations

for each vacation

begin

if(vacation.keptToBudget<0)

begin

print vacation.toString + "Budget is over budget as amount of "+vacation.keptToBudget();

end if

else

begin

   print vacation.toString + "Budget is underbudget as amount of "+vacation.keptToBudget();

end else

end loop

end main()

END class

Please let me know if you have any doubt or modify the answer, Thanks :)

Add a comment
Know the answer?
Add Answer to:
COVERT TO PSEUDOCODE /****************************Vacation.java*****************************/ public abstract class Vacation {    /*    * private data field...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • PLEASE COMPLETE THE CODES. package javaprogram; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; /** * Movie class...

    PLEASE COMPLETE THE CODES. package javaprogram; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; /** * Movie class definition. * * @author David Brown * @version 2019-01-22 */ public class Movie implements Comparable { // Constants public static final int FIRST_YEAR = 1888; public static final String[] GENRES = { "science fiction", "fantasy", "drama", "romance", "comedy", "zombie", "action", "historical", "horror", "war" }; public static final int MAX_RATING = 10; public static final int MIN_RATING = 0; /** * Converts a string of...

  • public class Item implements Comparable { private String name; private double price; /** * Constructor for...

    public class Item implements Comparable { private String name; private double price; /** * Constructor for objects of class Item * @param theName name of item * @param thePrice price of item */ public Item(String theName, double thePrice) { name = theName; price = thePrice; }    /** * gets the name * @return name name of item */ public String getName() { return name; }    /** * gets price of item * @return price price of item */...

  • public class Car {    /* four private instance variables*/        private String make;   ...

    public class Car {    /* four private instance variables*/        private String make;        private String model;        private int mileage ;        private int year;        //        /* four argument constructor for the instance variables.*/        public Car(String make) {            super();        }        public Car(String make, String model, int year, int mileage) {        super();        this.make = make;        this.model...

  • Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring;...

    Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring; public Person() {    this.numOffspring = 0; } public Person (int numOffspring) {    this.numOffspring = numOffspring; } public Person(String name, int birthYear, double weight, double height, char gender, int numCarryOn, int numOffspring) {    super(name, birthYear, weight, height, gender, numCarryOn);       if(numOffspring < 0) {        this.numOffspring = 0;    }    this.numOffspring = numOffspring; } public int getNumOffspring() {   ...

  • HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private...

    HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private int empNumber;    private double hoursWorked;    private double payRate;       private static int hospitalEmployeeCount = 0;    //-----------------------------------------------------------------    // Sets up this hospital employee with default information.    //-----------------------------------------------------------------    public HospitalEmployee()    { empName = "Chris Smith"; empNumber = 9999; hoursWorked = 0; payRate =0;               hospitalEmployeeCount++;    }       //overloaded constructor.    public HospitalEmployee(String eName,...

  • public class Date { private int month; private int day; private int year; /** default constructor...

    public class Date { private int month; private int day; private int year; /** default constructor * sets month to 1, day to 1 and year to 2000 */ public Date( ) { setDate( 1, 1, 2000 ); } /** overloaded constructor * @param mm initial value for month * @param dd initial value for day * @param yyyy initial value for year * * passes parameters to setDate method */ public Date( int mm, int dd, int yyyy )...

  • Java. What is the output of this code? Ace.java public class Ace { private double a;...

    Java. What is the output of this code? Ace.java public class Ace { private double a; public Ace ( double x) {       a = x; } public void multiply (double f) {       a *= x;         } public String toString () {       return String.format ("%.3f", x); AceDem.java public class AceDemo { public static void main(String args[]) {    Ace card = new Ace (2.133); card.multiply (.5); System.out.println (card); } }

  • 4. Command pattern //class Stock public class Stock { private String name; private double price; public...

    4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...

  • In Java. Please use the provided code Homework 5 Code: public class Hw05Source { public static...

    In Java. Please use the provided code Homework 5 Code: public class Hw05Source { public static void main(String[] args) { String[] equations ={"Divide 100.0 50.0", "Add 25.0 92.0", "Subtract 225.0 17.0", "Multiply 11.0 3.0"}; CalculateHelper helper= new CalculateHelper(); for (int i = 0;i { helper.process(equations[i]); helper.calculate(); System.out.println(helper); } } } //========================================== public class MathEquation { double leftValue; double rightValue; double result; char opCode='a'; private MathEquation(){ } public MathEquation(char opCode) { this(); this.opCode = opCode; } public MathEquation(char opCode,double leftVal,double rightValue){...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT