import java.util.Scanner;
public class station {
private int staStation;
private int endStation;
private int price;
private int money;
private int number;
public void station(){}
public void shuru_station(){
Scanner scanner = new Scanner(System.in);
System.out.println("请输入起始站");
staStation=scanner.nextInt();
System.out.println("请输入终点站");
endStation=scanner.nextInt();
System.out.println("请输入您要购买车票的数量");
number=scanner.nextInt();
}
public void price(){
int changdu=endStation-staStation;
if(changdu<=5){
price=3;
}
else if(changdu<=8){
price=4;
}
else{
price=5;
}
}
public void shuru_price(){
Scanner scanner = new Scanner(System.in);
System.out.println("您需要支付"+price*number+"元");
System.out.println("请支付");
money=scanner.nextInt();
}
public void compare(){
int money1=price*number;
int i=0;
for(;i<=3;i++){
int a=3-i;
int b=money-money1;
Scanner scanner = new Scanner(System.in);
System.out.println("您需要支付"+price*number+"元");
System.out.println("请支付");
money=scanner.nextInt();
if(money<money1){
System.out.println("您支付的金额不足,请重新支付");
System.out.println("您还有"+a+"次机会支付");
}
else if(money==money1){
System.out.println("正在为您打印车票");
break;
}
else {
System.out.println("正在为您打印车票,并找您"+b+"元");
break;
}
}
}
public static void main(String[] args) {
station s=new station();
s.shuru_station();
s.price();
s.compare();
}
}
尧叔
相关分类