java面试题:酒店预订!public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("是否是会员?y/n");
String H = input.next();
System.out.println("请输入入住日期:");
System.out.println("例如2009-03-16");
String in = input.next();
System.out.println("请输离开日期:");
System.out.println("例如2009-03-16");
String out = input.next();
//String in = s.substring(5,15);
//String out = s.substring(15,26);
//System.out.println(in "" out);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
try {
c1.setTime(sdf.parse(in));
c2.setTime(sdf.parse(out));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long time1 = c1.getTimeInMillis();
long time2 = c2.getTimeInMillis();
long tian = (time2-time1)/(1000*24*3600);
long tian1 = tian;
System.out.println("tian" tian);
int week1 = c1.get(Calendar.DAY_OF_WEEK)-1;
//System.out.println(week1);
//int week2 = c2.get(Calendar.DAY_OF_WEEK)-1;
//System.out.println(week2);
int count = 0;
while(tian10){
if(week1 == 6 || week1==0){
count;
}
if(week1==6){
week1 = 0;
【酒店预订房间java代码 java酒店预订系统】week1--;
}
tian1--;
week1;
}
System.out.println("count" count);
long rujia;
long qitian;
long hanting;
if(H.equals("y")){
rujia = (tian-count)*80 count*80;
System.out.println("tian" tian);
qitian = (tian-count)*110 count*50;
hanting = (tian-count)*100 count*40;
}else{
rujia = (tian-count)*110 count*90;
qitian = (tian-count)*160 count*60;
hanting = (tian-count)*220 count*150;
}
System.out.println("tian"tian);
System.out.println("rujia" rujia);
System.out.println("hanting" hanting);
System.out.println("qitian" qitian);
if(rujiaqitianrujiahanting){
System.out.println("如家");
}else if(qitianrujiaqitianhanting){
System.out.println("七天");
}else if(hantingrujiahantingqitian){
System.out.println("汉庭");
}else if(hanting==rujia || hanting==qitian){
System.out.println("汉庭");
}else if(qitian==rujiaqitianhanting){
System.out.println("七天");
}
}
我没怎么测试 自己测测吧 还有一些约束用户输入啥的 严谨性什么的
求用Java写的网上订房程序 要有酒店类 房间类 客户类 订房记录类 模拟一个人订房操作酒店类
package fdsa;
public class Hotel {
private StringhotelID;
private String hotelName;
private String hoteladdess;
public StringgetHotelID() {
return hotelID;
}
public void setHotelID(StringhotelID) {
this.hotelID = hotelID;
}
public String getHotelName() {
return hotelName;
}
public void setHotelName(String hotelName) {
this.hotelName = hotelName;
}
public String getHoteladdess() {
return hoteladdess;
}
public void setHoteladdess(String hoteladdess) {
this.hoteladdess = hoteladdess;
}
public String getHotelPhone() {
return hotelPhone;
}
public void setHotelPhone(String hotelPhone) {
this.hotelPhone = hotelPhone;
}
private String hotelPhone;
}
客户类
public class Client{
private String clientName;
private String clientID;
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public String getClientID() {
return clientID;
}
public void setClientID(String clientID) {
this.clientID = clientID;
}
}
房间类
public class Room{
private String roomID;
private HotelhotelID;
public String getRoomID() {
return roomID;
}
public void setRoomID(String roomID) {
this.roomID = roomID;
}
public Hotel getHotelID() {
return hotelID;
}
public void setHotelID(Hotel hotelID) {
this.hotelID = hotelID;
}
public String getRoomAmount() {
return roomAmount;
}
public void setRoomAmount(String roomAmount) {
this.roomAmount = roomAmount;
}
private String roomAmount;
}
求大神帮忙写下这个java程序import java.util.Scanner;
public class T1 {
static String [][] rooms = new String[12][10];
static {
for (int i=0;i12;i)
for (int j=0;j10;j)
rooms[i][j] = "EMPTY";
}
public static void main(String argv[]) {
System.out.println("XXX酒店管理程序加载完毕,请输入指令:");
Scanner sca = new Scanner(System.in);
while (true) {
String comm = sca.next();
if (comm.equalsIgnoreCase("Search")) {
search();
} else if (comm.equalsIgnoreCase("in")) {
System.out.println("输入客人姓名:");
String name = sca.next();
inRoom(name);
} else if (comm.equalsIgnoreCase("out")) {
System.out.println("输入客人房间号:");
int room = sca.nextInt();
outRoom(room/100, room0);
} else if (comm.equalsIgnoreCase("exit")) {
System.out.println("退出程序");
break;
} else {
System.out.println("无效的命令,请重新输入!");
}
}
sca.close();
}
private static void outRoom(int i, int j) {
if (i1 || i12 || j1 || j10) {
System.out.println("输入错误,请重新输入");
} else{
if (rooms[i-1][j-1].equalsIgnoreCase("empty")) {
System.out.printf("dd 并没有客人入住\n", i, j);
} else {
System.out.printf("OUT dd: dd房间退房,客人姓名:%s\n", i, j, i, j, rooms[i-1][j-1]);
rooms[i-1][j-1] = "EMPTY";
return;
}
}
}
private static void inRoom(String name) {
for (int i=0;i12;i) {
for (int j=0;j10;j) {
if (rooms[i][j].equalsIgnoreCase("EMPTY")) {
rooms[i][j] = name;
System.out.printf("INdd%s:姓名为%s的客人入住dd房间\n", i 1, j 1, name, name, i 1, j 1);
return;
}
}
}
}
private static void search() {
System.out.println("入住房间信息:");
System.out.println("---------------------------");
for (int i=0;i12;i) {
for (int j=0;j10;j) {
if (!rooms[i][j].equalsIgnoreCase("EMPTY")) {
System.out.printf("ROOM dd 客人:%s\n", i 1, j 1, rooms[i][j]);
}
}
}
System.out.println("---------------------------");
}
}
酒店预订房间java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java酒店预订系统、酒店预订房间java代码的信息别忘了在本站进行查找喔 。
推荐阅读
- html5读取pdf文件,html查看pdf
- 6岁儿童益智游戏,6岁儿童益智游戏app
- 直播带货直播运营,直播带货运营思路
- 拆分函数python 拆分函数 解不等式
- 旅行社如何利用新媒体传播,旅游企业如何利用新媒体营销
- ios降号怎么打,苹果手机降极
- 直播运营部门效能分析,直播运营工作总结范文大全
- vb.net如何添加窗体 vbnet mdi窗体
- python递归函数if,python递归函数斐波那契数列