Question
I'm getting the error Identifier Expected when trying to compile my subclasses and can't spot the error. Hoping someone can help me out. Thank you
I'm getting the error "Identifier Expected" when trying to compile my subclasses and can't spot the error. Hoping someone can help me out. Thank you for the help!
// abstract class
public abstract class Vacation { public abstract double Budget(); }
// subclass of the abstract class
public class AllInclusiveVacation extends Vacation { // initialize budget public double myBudget; public double budgetCompare; // Constructor for the class public AllInclusiveVacation(double myBudget) { this.myBudget = myBudget; } // method that prints out the brand public void Brand() { System.out.println("ClubMed"); } // method that prints out the rating public void Rating() { System.out.println("4 stars"); } // method that prints out price public double Price() { return 4500.62; } // method that compares the budget with the price public double Budget(myBudget) { budgetCompare = myBudget - 4500.62; return budgetCompare; } }
// test class
public class TestMyVacation { public static void main (String [] args) { // creating test objects AllInclusiveVacation Alpha = new AllInclusiveVacation(4500); PiecemealVacation Beta = new PiecemealVacation(3000); // not used yet System.out.print("Brand = " ); Alpha.Brand(); System.out.print("Rating = "); Alpha.Rating(); System.out.print("Price = $"); Alpha.Price(); System.out.print("Budget is (negative inicates under budget): "); Alpha.Budget();
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started