import java.util.Scanner;
public class PlaneTicket {
public static void main(String[] args){
int n=0;
PlaneNumber p=new PlaneNumber();
Discount d=new Discount();
p.setPrice(1000);
System.out.println("请输入需要购买的张数:");
Scanner scanner=new Scanner(System.in);
n=scanner.nextInt();
p.setNumber(n);
System.out.println(p.getPrice()*d.way());
}
}
--------------------------------------------------------------------
import java.util.Scanner;
public class PlaneNumber {
private int number,price;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getPrice() {
return price*number;
}
public void setPrice(int price) {
this.price = price;
}
}
--------------------------------------------------
public class Discount {
public double way(){
double dis=0.0;
PlaneNumber p=new PlaneNumber();
if(p.getNumber()>20){
dis=0.7;
}else if(p.getNumber()>=11){
dis=0.8;
}else{
dis=0.9;
}
return dis;
}
}
---------------------------------------------------------
最后在林版主的帮助下勉强做出来了,谢谢林大版主这么晚也不睡来教育我!
public class PlaneTicket {
public static void main(String[] args){
int n=0;
PlaneNumber p=new PlaneNumber();
Discount d=new Discount();
p.setPrice(1000);
System.out.println("请输入需要购买的张数:");
Scanner scanner=new Scanner(System.in);
n=scanner.nextInt();
p.setNumber(n);
System.out.println(p.getPrice()*d.way());
}
}
--------------------------------------------------------------------
import java.util.Scanner;
public class PlaneNumber {
private int number,price;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getPrice() {
return price*number;
}
public void setPrice(int price) {
this.price = price;
}
}
--------------------------------------------------
public class Discount {
public double way(){
double dis=0.0;
PlaneNumber p=new PlaneNumber();
if(p.getNumber()>20){
dis=0.7;
}else if(p.getNumber()>=11){
dis=0.8;
}else{
dis=0.9;
}
return dis;
}
}
---------------------------------------------------------
最后在林版主的帮助下勉强做出来了,谢谢林大版主这么晚也不睡来教育我!