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(tian1>0){
if(week1 == 6 || week1==0){
count++
}
if(week1==6){
week1 = 0
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(rujia<qitian &&rujia<hanting){
System.out.println("如家")
}else if(qitian<rujia &&qitian<hanting){
System.out.println("七天")
}else if(hanting<rujia &&hanting<qitian){
System.out.println("汉庭")
}else if(hanting==rujia || hanting==qitian){
System.out.println("汉庭")
}else if(qitian==rujia &&qitian<hanting){
System.out.println("七天")
}
}
我没怎么测试 自己测测吧 还有一些约束用户输入啥的 严谨性什么的
1、艺龙酒店预订2、携程酒店机票雹燃型火车票
3、去哪儿酒店预段迹定
4、朋友家精选民俗源猜
5、同程旅游
这些都可以预定的,去哪儿 携程 同城都还可以,还可以新人领取优惠券抵用,反正我就是用的这三个比较多。望采纳,祝你生活愉快。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)