- 分享
- 0
- 人气
- 0
- 主题
- 0
- 帖子
- 83
- UID
- 289813
- 积分
- 20
- 阅读权限
- 11
- 注册时间
- 2010-1-2
- 最后登录
- 2012-7-22
- 在线时间
- 367 小时
|
我的coding如下
import java.util.Scanner;
public class test
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
int menu;
int hourin, minutin, hourout, minutout, timeh, timem, newhourout, newminutout, round;
double charges;
System.out.println("Type of Vehicle?");
menu = input.nextInt();
switch(menu) {
case 1:
System.out.println("Hour vehicle entered lot (0-23)? ");
hourin = input.nextInt();
System.out.println("Minute vehicle entered lot (0-59)?");
minutin = input.nextInt();
System.out.println("Hour vehicle left lot (0-23)? ");
hourout = input.nextInt();
System.out.println("Minute vehicle left lot (0-60)?");
minutout = input.nextInt();
{
if (minutout < minutin){
newminutout = minutout + 60;
newhourout = hourout - 1;
timeh = newhourout - hourin;
timem = newminutout - minutin;
}
else{
timeh = hourout - hourin;
timem = minutout - minutin;
}
}
round = 60 - timem;
{
if (timeh > 0 && timeh < 4){
charges = 0;
}
else if(timeh > 3)
charges = ((timeh - 3)*1.5);
}
System.out.println("PARKING LOT CHARGE");
System.out.println("");
System.out.println("Type of vehicle: Car or Bus or Truck"+ menu) ;
System.out.println("TIME-IN "+hourin+":" + minutin);
System.out.println("TIME-OUT "+hourout+":"+ minutout);
System.out.println(" ----------------------------------");
System.out.println("PARKING TIME " + timeh + ":" + timem);
System.out.println("ROUNDED TOTAL : " + round + "");
System.out.println(" ----------------------------------");
System.out.println("TOTAL CHARGE RM " + charges + "");
break;
case 2:
System.out.println("Hour vehicle entered lot (0-23)? ");
hourin = input.nextInt();
System.out.println("Minute vehicle entered lot (0-59)?");
minutin = input.nextInt();
System.out.println("Hour vehicle left lot (0-23)? ");
hourout = input.nextInt();
System.out.println("Minute vehicle left lot (0-60)?");
minutout = input.nextInt();
{
if (minutout < minutin){
newminutout = minutout + 60;
newhourout = hourout - 1;
timeh = newhourout - hourin;
timem = newminutout - minutin;
}
else{
timeh = hourout - hourin;
timem = minutout - minutin;
}
}
round = 60 - timem;
{
if (timeh > 0 && timeh < 3){
charges = timeh*1;
}
else if(timeh > 2)
charges = ((timeh - 2)*2.3);
}
System.out.println("PARKING LOT CHARGE");
System.out.println("");
System.out.println("Type of vehicle: Car or Bus or Truck"+ menu) ;
System.out.println("TIME-IN "+hourin+":" + minutin);
System.out.println("TIME-OUT "+hourout+":"+ minutout);
System.out.println(" ----------------------------------");
System.out.println("PARKING TIME " + timeh + ":" + timem);
System.out.println("ROUNDED TOTAL : " + round + "");
System.out.println(" ----------------------------------");
System.out.println("TOTAL CHARGE RM " + charges + "");
break;
case 3:
System.out.println("Hour vehicle entered lot (0-23)? ");
hourin = input.nextInt();
System.out.println("Minute vehicle entered lot (0-59)?");
minutin = input.nextInt();
System.out.println("Hour vehicle left lot (0-23)? ");
hourout = input.nextInt();
System.out.println("Minute vehicle left lot (0-60)?");
minutout = input.nextInt();
{
if (minutout < minutin){
newminutout = minutout + 60;
newhourout = hourout - 1;
timeh = newhourout - hourin;
timem = newminutout - minutin;
}
else{
timeh = hourout - hourin;
timem = minutout - minutin;
}
}
round = 60 - timem;
{
if (timeh > 0 && timeh < 2){
charges = timeh*2;
}
else if(timeh > 2)
charges = ((timeh - 3)*3.7);
}
System.out.println("PARKING LOT CHARGE");
System.out.println("");
System.out.println("Type of vehicle: Car or Bus or Truck"+ menu) ;
System.out.println("TIME-IN "+hourin+":" + minutin);
System.out.println("TIME-OUT "+hourout+":"+ minutout);
System.out.println(" ----------------------------------");
System.out.println("PARKING TIME " + timeh + ":" + timem);
System.out.println("ROUNDED TOTAL : " + round + "");
System.out.println(" ----------------------------------");
System.out.println("TOTAL CHARGE RM " + charges + "");
break;
default:
System.out.println("Invalid Entry!");
}
}
}
我compile和run不到。
请各位高手帮帮忙和指点指点
谢谢 |
|