Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When trying to run VacationBookingMain.java program with the below VacationBooking.java class, I am getting a Error: Main method not found in class com.mycompany.vacationbooking.VacationBooking, please define

When trying to run VacationBookingMain.java program with the below VacationBooking.java class, I am getting a

Error: Main method not found in class com.mycompany.vacationbooking.VacationBooking, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application Command execution failed.

Help!! Program is in Java

Program 1

VacationBookingMain.java

import java.util.Scanner;

public class VacationBookingMain { public static void main(String[] args) { Scanner sc = new Scanner(System.in); VacationBooking[] orders = new VacationBooking[2];

// Get data from user for two vacation bookings for (int i = 0; i < 2; i++) { System.out.println("Enter data for customer " + (i + 1) + ":"); System.out.print("Customer Name: "); String customerName = sc.nextLine(); System.out.print("Hotel Name: "); String hotelName = sc.nextLine(); System.out.print("Room Number: "); int roomNumber = sc.nextInt(); System.out.print("Days Reserved: "); int daysReserved = sc.nextInt(); System.out.print("Event Tickets: "); double eventTickets = sc.nextDouble(); sc.nextLine(); // consume the newline character left in the buffer

// create a VacationBooking object with full constructor orders[i] = new VacationBooking(customerName, hotelName, roomNumber, daysReserved, eventTickets); }

// Show customer name, hotel name, and vacation price for each order System.out.println(" ---Initial Orders---"); for (int i = 0; i < 2; i++) { System.out.println(" Order " + (i + 1)); System.out.println("Customer Name: " + orders[i].getCustomerName()); System.out.println("Hotel Name: " + orders[i].getHotelName()); System.out.println("Vacation Price: $" + orders[i].showVacationPrice()); }

// Ask user for a change in number of days for one order System.out.println(" Enter the order number for which you want to change the number of days: "); System.out.println("Enter the new number of days: "); int newDays = sc.nextInt(); VacationBooking.setDaysReserved(newDays);

// Show customer name, hotel name, and vacation price for each order after the change System.out.println(" ---Orders after the change---"); for (int i = 0; i < 2; i++) { System.out.println(" Order " + (i + 1)); System.out.println("Customer Name: " + orders[i].getCustomerName()); System.out.println("Hotel Name: " + orders[i].getHotelName()); System.out.println("Vacation Price: $" + orders[i].showVacationPrice()); } } }

Program 2

VacationBooking.java

public class VacationBooking {

private String customerName; private String hotelName; private int roomNumber; private int daysReserved; private double eventTickets; public VacationBooking(String customerName, String hotelName, int roomNumber, int daysReserved, double eventTickets) { setCustomerName(customerName); setHotelName(hotelName); setRoomNumber(roomNumber); setDaysReserved(daysReserved); setEventTickets(eventTickets); }

public String getCustomerName() { return customerName; }

private void setCustomerName(String customerName) { this.customerName = customerName; } public String getHotelName() { return hotelName; } private void setHotelName(String hotelName){ this.hotelName = hotelName; } public int getRoomNumber() { return roomNumber; } private void setRoomNumber(int roomNumber) { this.roomNumber = roomNumber; } public int getDaysReserved() { return daysReserved; } public static void setDaysReserved(int daysReserved) { if (daysReserved < 0) { throw new IllegalArgumentException("Days reserved cannot be negative"); } }

public double getEventTickets() { return eventTickets; }

public static void setEventTickets(double eventTickets) { if (eventTickets < 0) { throw new IllegalArgumentException("Event tickets cannot be negative"); } }

public double showVacationPrice() { double basePrice = daysReserved * 1000 + eventTickets; double tax = basePrice * 0.05; return basePrice + tax; } }

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

Students also viewed these Databases questions

Question

=+Does it showcase the firm's benefits?

Answered: 1 week ago

Question

=+ Does it list exciting places to go and famous sites to see?

Answered: 1 week ago