Question: Customer Class =========================================================================== class customer { private int userID; private String name, email; private booking b; public customer() { this.b = new booking(); this.userID =

Customer Class

===========================================================================

class customer { private int userID; private String name, email; private booking b; public customer() { this.b = new booking(); this.userID = 0; this.name = " "; this.email = " "; } public customer ( int id, String n, String e,String pa, int dd, int rd, int nop) { this.b = new booking (); this.userID = userID; this.name = name; this.email = email; } public int getUserID() { return userID; } public String getName() { return name; } public String getEmail() { return email; } public String getPack() { String pack; pack = b.getPack(); return pack; } public int getDepartDate() { int departDate; departDate = b.getDepartDate(); return departDate; } public int getReturnDate() { int returnDate; returnDate = b.getReturnDate(); return returnDate; } public int getNumOfPax() { int numOfPax; numOfPax = b.getNumOfPax(); return numOfPax; } public String toString() { return "User ID: "+userID+" Name: "+name+" Email: "+email+" Package: "+b.getPack()+" Depart Date: "+b.getDepartDate()+" Return Date: "+b.getReturnDate()+" Num Of Pax: "+b.getNumOfPax(); } }

============================================================================================================

Booking Class

============================================================================================================

class booking { private String pack; private String type; private int departDate; private int returnDate; private int numOfPax; private double price; public booking () { } public booking (String pa, String t, int dd, int rd, int nop, double p) { pack = pa; type = t; departDate = dd; returnDate = rd; numOfPax = nop; price = p; } public void setData (String pa, String t, int dd, int rd, int nop, double p) { pack = pa; type = t; departDate = dd; returnDate = rd; numOfPax = nop; price = p; } public String getPack() { return pack; } public String getType() { return type; } public int getDepartDate() { return departDate; } public int getReturnDate() { return returnDate; } public int getNumOfPax() { return numOfPax; } public double getPrice() { return price; } public double totalPayment () { double newPrice; double govTax; double serviceTax; double totalPrice; double transPrice; if (type.equalsIgnoreCase("Silver")) { price = 1500; System.out.println("Transport colour is White"); } else if (type.equalsIgnoreCase("Gold")) { price = 2000; System.out.println("Transport colour is Blue"); } else if (type.equalsIgnoreCase("Platinum")) { price = 3000; System.out.println("Transport colour is Red"); } govTax = 0.03; serviceTax = 0.10; transPrice = 200; totalPrice = price + transPrice; newPrice = totalPrice + (totalPrice * 0.03) + (totalPrice * 0.10); return newPrice; } public String toString() { return "Pack:"+pack+" DepartDate: "+departDate+" ReturnDate: "+returnDate+" Num Of Pax: "+numOfPax+" Total Payment: "+totalPayment(); } }

================================================================================================================================

Transport Class

================================================================================================================================

class transport { private String type; private double price; public transport() { } public transport (String t, double p) { type = t; price = p; } public void setData (String t, double p) { type = t; price = p; } public String getType() { return type; } public double getPrice() { return price; } public double calPrice() { double transPrice; double totalPrice; transPrice = 200; if (type.equalsIgnoreCase("Silver")) { price = 1500; System.out.println("Transport Colour is White"); } else if (type.equalsIgnoreCase("Gold")) { price = 2000; System.out.println("Transport Colour is Blue"); } else if (type.equalsIgnoreCase("Platinum")) { price = 3000; System.out.println("Transport Colour is Red"); } totalPrice = price + transPrice; return totalPrice; } public String toString() { return " "+super.toString()+" Type: "+type+" Price: "+price; } }

====================================================================================================================================

Main Class

====================================================================================================================================

import javax.swing.*; import java.util.*;

public class bookingApp { public static void main ( String [] args ) { Scanner scan = new Scanner (System.in); System.out.println("======================================"); System.out.println("Welcome to Sri Putra Budget Travel "); System.out.println("======================================"); System.out.println("Please enter Depart Date: "); int departDate = scan.nextInt(); System.out.println("Please enter Return Date: "); int returnDate = scan.nextInt(); System.out.println("Please enter the Number of Pax: "); int numOfPax= scan.nextInt(); System.out.println(" Please enter your Type Package: "); String type= scan.nextLine(); System.out.println("*******************************"); System.out.println(" Silver, Gold, Platinum "); System.out.println("*******************************"); String pack = scan.next(); double price = 0; booking b = new booking(); b.setData(pack,type,departDate,returnDate,numOfPax,price); b.totalPayment(); System.out.println(b.toString()); } }

=============================================================================================================

QUESTION :

With all the class given above, you need to make a complete program which allows users to enter their own input and this program must accept various input from user.You also need to include inheritance concept in this program. If you think any shortage from the class given you also need to make a new class or do some improvement for this program.This program is in java language. For you reference, this program is about travel agency booking system.

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!