The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Sabbir java code
By Guest on 16th January 2023 12:32:42 PM | Syntax: TEXT | Views: 2



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. import java.util.Scanner;
  2. class HelloWorld {
  3.     public static void main(String[] args) {
  4.         //Welcome message
  5.         System.out.println("Welcome to the movie, Puss in boots!\n");
  6.        
  7.         Scanner input = new Scanner(System.in);
  8.        
  9.         // Getting String input
  10.         System.out.print("Please enter your name: ");
  11.         String name = input.next();
  12.         System.out.println("Hope you're well, " + name + "! To buy movie tickets, please enter the number of pax:\n");
  13.         //Getting input for tickets
  14.         System.out.print("Adult (RM22.00): ");
  15.         int adult = input.nextInt();
  16.         System.out.print("Children (RM16.00): ");
  17.         int children = input.nextInt();
  18.         System.out.print("Senior Citizen (RM9.00): ");
  19.         int senior = input.nextInt();
  20.         //Thank you message
  21.         System.out.println("Thank you! Please find the summary as below:\n");
  22.         System.out.println("Number of adult: " + adult + " adults");
  23.         int tot_adult = 22 * adult;
  24.         System.out.println("Total price for adults: " + tot_adult);
  25.         System.out.println("Number of children: " + children + " children");
  26.         int tot_children = 16 * children;
  27.         System.out.println("Total price for children: " + tot_children);
  28.         System.out.println("Number of senior citizens: " + children + " senior citizens");
  29.         int tot_senior = 9 * children;
  30.         System.out.println("Total price for senior citizen: " + tot_senior);
  31.         int add = adult + children + senior;
  32.         int total = tot_adult + tot_children + tot_senior;
  33.         System.out.println("Number of tickets purchased: " + add);
  34.         System.out.println("Total price is: " + total);
  35.         System.out.println("Thank you!");
  36.     }
  37. }



  • Recent Pastes
  • Questions
    14 hours 10 mins 25 secs ago
  • Adrs
    14 hours 15 mins 35 secs ago
  • Docs
    14 hours 16 mins 19 secs ago
  • Servs
    14 hours 17 mins 2 secs ago
  • Srvs
    14 hours 21 mins 51 secs ago