import java.util.Scanner;
public class W{
public static void main(String args[]){
int station=0;
int people =0;
while(true){
Scanner sc=new Scanner(System.in);
System.out.printf("\n\n请输入人数");
people=sc.nextInt();
System.out.println("请输入站数");
station=sc.nextInt();
if(people>0 && station>0){
if (station>9)
System.out.printf("票价是%d",5*people);
switch(station){
case 1:
case 2:
case 3:
case 4: System.out.printf("票价是%d",3*people);
break;
case 5:
case 6:
case 7:
case 8:
case 9: System.out.printf("票价是%d",4*people);
break;
}
}
else System.out.println("输入错误,请再次输入");
}
}
}
用java编写购买地铁车票的规定如下:乘1-4站,3元/位;乘5-9站,4元/位;乘9站以上,5元/位,编写一个程序:(1) 输入人数、站数,输出应付款;
最新推荐文章于 2024-03-20 12:52:02 发布