Advertisement
skipter

Vacantion - Exam Java BAsic 20 Nov

Apr 29th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FOX {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.  
  7.         int oldPeople = Integer.parseInt(input.nextLine());
  8.         int students = Integer.parseInt(input.nextLine());
  9.         int nights = Integer.parseInt(input.nextLine());
  10.         String transport = input.nextLine();
  11.  
  12.         double oldPeopleTransportPrice = 0;
  13.         double studentsTransportPrice = 0;
  14.  
  15.         if (transport.equals("train")) {
  16.             oldPeopleTransportPrice = 24.99;
  17.         } else if (transport.equals("airplane")) {
  18.             oldPeopleTransportPrice = 70.00;
  19.         } else if (transport.equals("boat")) {
  20.             oldPeopleTransportPrice = 42.99;
  21.         } else if (transport.equals("bus")) {
  22.             oldPeopleTransportPrice = 32.50;
  23.         }
  24.         if (transport.equals("train")) {
  25.             studentsTransportPrice = 14.99;
  26.         } else if (transport.equals("airplane")) {
  27.             studentsTransportPrice = 50.00;
  28.         } else if (transport.equals("boat")) {
  29.             studentsTransportPrice = 39.99;
  30.         } else if (transport.equals("bus")) {
  31.             studentsTransportPrice = 28.50;
  32.         }
  33.  
  34.         if (oldPeople + students >= 50 & transport.equals("train")) {
  35.             studentsTransportPrice = studentsTransportPrice / 2;
  36.             oldPeopleTransportPrice = oldPeopleTransportPrice / 2;
  37.         }
  38.  
  39.         double hotelNight = 82.99;
  40.         double transportTaxes = ((oldPeople * oldPeopleTransportPrice) + (students * studentsTransportPrice)) * 2;
  41.         double hotelTax = nights * hotelNight;
  42.         double commission = (transportTaxes + hotelTax) * 0.10;
  43.         double total = transportTaxes + hotelTax + commission;
  44.  
  45.  
  46.  
  47.         System.out.printf("%.2f", total);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement