gui java 关闭,java - 从已经编写的Java代码创建GUI [关闭] - 堆栈内存溢出

已关闭 。

这个问题需要更加集中 。

它当前不接受答案。

想改善这个问题吗? 更新问题,使其仅通过编辑此帖子来关注一个问题。

1小时前关闭。

我有一些无法转换为GUI的代码,我被认为是1)为登录屏幕创建GUI以访问系统; (2)允许用户客户选择酒店及其位置,预订天数,预订日期,房间住宿以及任何适用的折扣; (3)返回预订总费用和用户输入的所有数据的收据。 总成本应反映营业税和任何适用的折扣; (4)允许用户选择付款方式(VISA,MasterCard,Discover Card,PayPal,ApplePay等); (5)重复申请新订单的能力。 我已经写了大部分代码,但似乎无法弄清楚如何将其转换为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 = '\0';

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: $%.2f\n ",

RealPrice);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值