java代码以及报错如下,语法没有错误,应该是哪里逻辑错了,也不长,也不复杂,希望各位大神帮助!这下面是代码:importjava.util.Scanner;publicclassjava0608{publicstaticvoidmain...
java代码以及报错如下,语法没有错误,应该是哪里逻辑错了,也不长,也不复杂,希望各位大神帮助!
这下面是代码:
import java.util.Scanner;
public class java0608 {
public static void main(String[] args){ // strat the main function
String Y = null,N = null;//我不知道null是什么类型的,能否说一声?
Scanner input = new Scanner(System.in);
String p="";
double total = 0;
do {System.out.print("Please enter the custmer's name :");
String name=input.nextLine();
System.out.print("Please enter the custmer's parking time :");
double t=input.nextDouble();
System.out.printf("%s cost %d $:",name,caculater(t));//代码应该是这里错了,因为我删除这里之后后面的可以运行,但是就是没有让用户输入N或者Y就直接把total输出。。。。。
System.out.print("would you want to finish the caculating? If that ,you can enter Y,whereas enter N");
p=input.nextLine();
total= caculater(t)+total;
}while (p.equals(N));
System.out.printf("the totle receipts is :%s",total);
}
public static double caculater(double t){// strat the caculater method
double price = 0;
if(t==1.00|t==2.00|t==3.00){
price=2.00;
}
else if(t==24.00){
price=10.00;
}
else price=2.00+0.5*(t-3);
return price;
}}
展开