[go: up one dir, main page]

0% found this document useful (0 votes)
42 views2 pages

Ticket Fare Java

The document is a Java program that calculates the total fare for a ticket based on various inputs such as ticket price, meal, insurance, seat selection, rebooking fee, and baggage weight. It determines the baggage fee based on the weight of the baggage and calculates the subtotal, tax, and total amount. The program then outputs the customer's name and all calculated values to the console.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Ticket Fare Java

The document is a Java program that calculates the total fare for a ticket based on various inputs such as ticket price, meal, insurance, seat selection, rebooking fee, and baggage weight. It determines the baggage fee based on the weight of the baggage and calculates the subtotal, tax, and total amount. The program then outputs the customer's name and all calculated values to the console.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*

* To change this license header, choose License Headers in Project


Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package TicketFare;

import java.util.Scanner;

/**
*
* @author pc
*/
public class TicketFare {

private static int bag_fee;


public static void main(String[] args) {
String Customer_name;
Double pri_ticket,meal,insurance,seat,re_fee, weight_bagg,
bagg_fee, sub_total,tax,t_amount;
Scanner mar = new Scanner (System.in);

System.out.println("Customer's Name: ");


Customer_name = mar.nextLine();

System.out.println("Price of Ticket: ");


pri_ticket = mar.nextDouble();

System.out.println("Meal: ");
meal = mar.nextDouble();

System.out.println("Insurance: ");
insurance = mar.nextDouble();

System.out.println("Seat: ");
seat = mar.nextDouble();

System.out.println("Rebooking Fee: ");


re_fee = mar.nextDouble();

System.out.println("Weight of Baggage:");
weight_bagg = mar.nextDouble();

if (weight_bagg >= 1 && weight_bagg <= 20){


bag_fee = 700;
}
else if (weight_bagg >= 21 && weight_bagg <= 32){
bag_fee = 1350;
}
else if (weight_bagg >= 33 && weight_bagg <= 40){
bag_fee = 1900;
}
else if (weight_bagg >= 41 && weight_bagg <= 70){
bag_fee = 2500;
}
else {
bag_fee = 3500;
}

sub_total = meal + seat + re_fee + insurance + pri_ticket +


bag_fee;
tax = sub_total * 0.12;
t_amount = tax + sub_total;

System.out.println("Customer's Name: " + Customer_name);


System.out.println("Price of Ticket: " + pri_ticket);
System.out.println("Meal: " + meal);
System.out.println("Insurance:" + insurance);
System.out.println("Seat: " + seat);
System.out.println("Rebooking Fee: " + re_fee);
System.out.println("Baggage Fee:" + bag_fee);
System.out.println("SubTotal: " + sub_total);
System.out.println("Tax:" + tax);
System.out.println("Total Amount:" + t_amount);

You might also like