Plan the logic for an airport services company program to de

Plan the logic for an airport services company program to determine service fees. The program prompts the user for their name and the type of service needed—parking or shuttle. Depending on the service type, the program gets additional information from the user and then calls one of the methods described below, to determine their fee, and then displays the user’s name, the service type and the fee. The methods are:

a) calculateParkingFee method i) requires to be passed information (“Y” or “N”) that indicates whether the user is a member of the company’s frequent parker program, and the number of days of parking required

ii) if the user is a member, they receive a 10% discount on the regular parking fee of $12 per day

iii) the method returns the total parking fee

b) calculateShuttleFee method i) requires to be passed the number of passengers and the total number of bags being brought by the passengers

ii) determines the shuttle fee as follows: (1) a base fee of $29 per passenger (2) the base fee includes one free bag per passenger; any additional bags are charged a fee of $2 each

iii) the method returns the total shuttle fee

Solution

The program is as follows:

Airplane.java:

import java.util.Scanner;

public class Airport {

   public static void main(String args[]){

       System.out.println(\"What\'s your name\");
       Scanner scanner = new Scanner(System.in);
       System.out.flush();
       String name= scanner.nextLine();
       System.out.println(\"Which service do you need? Parking or Shuttle?\");
       String serviceType=scanner.nextLine();

       float totalFee;
       if(serviceType.equalsIgnoreCase(\"parking\")){
      
           System.out.println(\"Are you a member of company\'s frequent parker program? Enter Y or N\");
           String option1=scanner.nextLine();
           System.out.println(\"Enter the number of days for which you require parking\");
           int option2=Integer.parseInt(scanner.nextLine());
           totalFee=calculateParkingFee(option1,option2);
           System.out.println(\"User Name : \" + name+ \"\ Service Type : Parking\"+\"\ Fee : $\" + totalFee);
       }
       else if(serviceType.equalsIgnoreCase(\"shuttle\")){
           System.out.println(\"Enter the number of passengers\");
           int option1=Integer.parseInt(scanner.nextLine());
           System.out.println(\"Enter the number of bags\");
           int option2=Integer.parseInt(scanner.nextLine());
           totalFee=calculateShuttleFee(option1,option2);
           System.out.println(\"User Name : \" + name+ \"\ Service Type : Shuttle\"+\"\ Fee : \" + totalFee);

       }
       else{
           System.out.println(\"That\'s not a valid option.\");
           }

   }
  
   public static float calculateParkingFee(String option1, int option2){
       float amount=12*option2;
       if(option1.equals(\"Y\")){
           amount=(float) 0.9 * amount ;
       }
       return amount;
   }
  
   public static float calculateShuttleFee(int option1, int option2){
       float amount=29*option1;
       if(option2-option1>0){
           amount+=(float) (option2-option1)*2 ;
       }
       return amount;
   }
}

Sample runs:

1) What\'s your name
lok
Which service do you need? Parking or Shuttle?
parking
Are you a member of company\'s frequent parker program? Enter Y or N
Y
Enter the number of days for which you require parking
10
User Name : lok
Service Type : Parking
Fee : $108.0

2) What\'s your name
Andrea
Which service do you need? Parking or Shuttle?
shuttle
Enter the number of passengers
10
Enter the number of bags
30
User Name : Andrea
Service Type : Shuttle
Fee : 330.0

Plan the logic for an airport services company program to determine service fees. The program prompts the user for their name and the type of service needed—par
Plan the logic for an airport services company program to determine service fees. The program prompts the user for their name and the type of service needed—par

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site