
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Phone huawei = new Phone( "华为", 5.5, 3688.88, "8+128g 全面刘海");
Phone millet = new Phone( "小米", 5.0, 2988.88, "4+64g 全面屏 ");
System.out.println("品牌型号:"+huawei.brand+"\n尺寸:"+huawei.size+"\n价格:"+huawei.price+"\n配置:"+huawei.configuration);
System.out.println("请输入华为手机库存");
huawei.stock = s.nextInt();
huawei.total_price = huawei.stock * huawei.price;
System.out.println("品牌型号:"+millet.brand+"\n尺寸:"+millet.size+"\n价格:"+millet.price+"\n配置:"+millet.configuration);
System.out.println("请输入小米手机库存");
millet.stock= s.nextInt();
millet.total_price = millet.stock * millet.price;
System.out.println("------------库存清单-------------");
System.out.println("品牌型号\t尺寸\t价格\t\t\t配置\t\t库存数量\t总价");
System.out.println(huawei.brand+"\t\t"+huawei.size+"\t"+huawei.price+"\t"+huawei.configuration+"\t"+huawei.stock+"\t"+huawei.total_price);
System.out.println(millet.brand+"\t\t"+millet.size+"\t"+millet.price+"\t"+millet.configuration+"\t"+millet.stock+"\t"+millet.total_price);
System.out.println("--------------------------------\n总库存:"+(huawei.stock+millet.stock)+"\n库存总价:"+(huawei.total_price+millet.total_price)+"¥");
}
}
class Phone {
int stock; //库存数量
String brand;
double size;
double price;
String configuration;
double total_price; //总价
public Phone(String brand, double size, double price, String configuration) {
this.brand = brand;
this.size = size;
this.price = price;
this.configuration = configuration;
}
}