import java.Scanner; import java.*; import java.event.*; import javax.swing.
View the step-by-step solution to:

Question

I have some code that I'm having trouble converting into GUI, please help out!

/>

   

  import java.util.Scanner;

  import java.awt.*;

  import java.awt.event.*;

  import javax.swing.*;

   

  public class Reservation

  {

   static Scanner sc = new Scanner(System.in);

   public static void main(String args[])

   {

     

    // the local variables declared and initialized

    char answer = 'Y', specEvent = 'N', rateCode = '';

    String char1="", char2="",choice1="";

    int days = 0,Selection=0,room=0,cost=0;

    int num= 0,Status=0;

    double FinalCost=0.0,RealPrice=0.0;

    double discount=0.0,tax=0.0;

    

   System.out.println("Welcome to the North Hotel Reservation System");

   System.out.println("");

   System.out.println("");

   System.out.println("***************************");

    

   //Request the name of the customer

    System.out.println("Please enter your first name");

    char1=sc.nextLine();

    System.out.println("Please enter your second name");

    char2=sc.nextLine();

    System.out.println("Welcome "+ char1 +" "+ char2+".");

  System.out.println("");

    System.out.println("We have 7 hotels available, please select the number tied to the hotel you wish to accomodate");

    System.out.println("");

    System.out.println("Ritz-Carlton  1"+"n"+"Comfort Inn  2" );

    System.out.println("Hyatt  3"+"n"+"The View Hotel  4" );

    System.out.println("Grand Hotel  5"+"n"+"Plaza Hotel  6"+"n"+"Royal York Hotel  7" );

    System.out.println("");

    Selection=sc.nextInt();

     

    switch (Selection) {

    case 1:

      System.out.print("Ritz-Carlton in Chicago, IL" );

      choice1=choice1+("Ritz-Carlton in Chicago, IL");

      break;

    case 2:

     System.out.print("Comfort Inn in Madison, WI" );

     choice1=choice1+("Comfort Inn in Madison, WI");

     break;

    case 3:

     System.out.print("Hyatt in Los Angeles, CA" );

     choice1=choice1+("Hyatt in Los Angeles, CA");

     break;

    case 4:

     System.out.print("The View Hotel in Sussex, UK" );

     choice1=choice1+("The View Hotel in Sussex, UK");

     break;

    case 5:

     System.out.print("Grand Hotel in Makinac,MI" );

     choice1=choice1+("Grand Hotel in Makinac,MI");

     break;

    case 6:

     System.out.print("Plaza Hotel in New York,NY" );

     choice1=choice1+("Plaza Hotel in New York,NY");

     break;

    case 7:

     System.out.print("Royal York Hotel in Toronto" );

     choice1=choice1+("Royal York Hotel in Toronto");

     break;

    }

    System.out.println("");

    System.out.println("How many days do you wish to stay?");

    days = sc.nextInt();

    System.out.println("You indicate that you want to stay for " + (days)+" Days,");

    System.out.println("");

    System.out.println("We have 7 Room Types available");

    System.out.println("");

     

    System.out.println("Double Bed 1"+"n"+"Single Bed(Larger) 2" );

    System.out.println("Suite 3"+"n"+"Single Bed 4" );

    System.out.println("Bridle Suite 5"+"n"+"Mega Suites 6"+"n"+ "Single bed(Largest)  7" );

    System.out.println("");

    room=sc.nextInt();

    System.out.println("Price Per Night(USD): ");

    switch (room) {

    case 1:

      System.out.println("Double Bed 350(USD) a night" );

      cost=350;

      tax=0.09*cost;

      break;

    case 2:

     System.out.println("Single Bed(Larger) 141(USD) a night" );

      cost=141;

      tax=0.07*cost;

     break;

    case 3:

     System.out.println("Suite for 150(USD) a night" );

      cost=150;

      tax=0.1*cost;

     break;

    case 4:

     System.out.println("Single Bed 61(USD) a night" );

      cost=61;

      tax=0.01*cost;

     break;

    case 5:

     System.out.println("Bridle Suite for 380(USD) a night" );

      cost=380;

      tax=0.06*cost;

     break;

    case 6:

     System.out.println("Mega Suites for 800(USD) a night" );

      cost=800;

      tax=0.08*cost;

     break;

    case 7:

     System.out.println("Single bed(Largest) for 314(USD) a night" );

     cost=314;

     tax=0.07*cost;

      break;

    }

    System.out.println("");

    System.out.println("How many rooms?");

    num=sc.nextInt();

    System.out.println("***************************");

    System.out.println("");

     

    System.out.println("Based on your input,your name is "+char1+" "+char2+",n you want to stay in "+choice1);

    System.out.print("Do you wish to Continue? (Y/N)");

    answer=sc.next().charAt(0);

    while(answer == 'Y' || answer == 'y')

    {

     System.out.print("Where do you classify yourself,n");

     System.out.println("Student(1),Senior(2),Birthday(3),Coporate(4),None(0)");

     Status=sc.nextInt();

      

     FinalCost=cost*days*num+tax;

     switch (Status) {

     case 1:

       System.out.println("10 percent off" );

       discount=0.1*FinalCost;

       RealPrice=FinalCost-discount;

       break;

     case 2:

      System.out.println("20 percent off" );

       discount=0.2*FinalCost;

       RealPrice=FinalCost-discount;

      break;

     case 3:

      System.out.println("15 percent off" );

       discount=0.15*FinalCost;

       RealPrice=FinalCost-discount;

      break;

     case 4:

      System.out.println("25 percent off" );

      discount=0.25*FinalCost;

      RealPrice=FinalCost-discount;

       break;

     default:

     System.out.println("No discount");

     RealPrice=FinalCost;

     }

     

     System.out.printf("With All the values given,your total charge is: $%.2fn " ,RealPrice);

     

    }

    }

   }

   

     

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes