import java.util.Scanner;
public class subway {
private int price;
private int staStation;
private int endStation;
private int money;
private int number;
public void subway(){}
public void price1(){
int number1=endStation-staStation;
if(number1<=5){
price=3;
}
else if(number1<=8){
price=4;
}
else{
price=5;
}
}
public void shuru(){
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 shuru1(){
Scanner scanner =new Scanner(System.in);
int tatPrice1=number*price;
System.out.println("您需要支付"+tatPrice1+"元");
System.out.println("请支付");
money=scanner.nextInt();
}
public void pay(){
int tatPrice=number*price;
if(money<tatPrice){
System.out.println("您支付的金额不足");
}
else if(money==tatPrice){
System.out.println("正在帮您打印车票");
}
else{
int money1=money-tatPrice;
System.out.println("正在帮您打印车票并找您"+money1+"元");
}
}
public static void main(String[] args) {
subway s=new subway();
s.shuru();
s.shuru1();
s.price1();
s.pay();
}
}
MinRam
相关分类