I have some code that I'm having trouble converting into GUI, i am is supposed 1)create GUI for a logon screen to access the system;
(我有一些无法转换为GUI的代码,我被认为是1)为登录屏幕创建GUI以访问系统;)
(2) allow the user-customer to choose the hotel and its location, the number of days to reserve, the date to reserve, the room accommodations, and any applicable discount;((2)允许用户客户选择酒店及其位置,预订天数,预订日期,房间住宿以及任何适用的折扣;)
(3) returns a receipt of total cost for the reservation and all the data entered by the user.((3)返回预订总费用和用户输入的所有数据的收据。)
The total cost is to reflect the sales tax and any applicable discount;(总成本应反映营业税和任何适用的折扣;)
(4) allow the user to choose a payment option (VISA, MasterCard, Discover Card, PayPal, ApplePay, etc.);((4)允许用户选择付款方式(VISA,MasterCard,Discover Card,PayPal,ApplePay等);)
and (5) the ability to repeat the application for a new order.((5)重复申请新订单的能力。)
I have already written most of the code but I cant seem to figure out how to turn it into a GUI.(我已经写了大部分代码,但似乎无法弄清楚如何将其转换为GUI。)
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" + "
" + "Comfort Inn 2");
System.out.println("Hyatt 3" + "
" + "The View Hotel 4");
System.out.println("Grand Hotel 5" + "
" + "Plaza Hotel 6" + "
" + "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" + "
" + "Single Bed(Larger) 2");
System.out.println("Suite 3" + "
" + "Single Bed 4");
System.out.println("Bridle Suite 5" + "
" + "Mega Suites 6" + "
" + "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
+ ",
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,
");
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: $%.2f
",
RealPrice);
}
}
}
ask by Chinmeri Nwagwu translate from so