Java基础入门——直接打印商品库存清单
程序员文章站
2022-03-10 08:38:06
Java基础入门——打印商品库存清单package experiment01;public class Goods { public static void main(String[] args) {...
package experiment01;
public class Goods {
public static void main(String[] args) {
// 苹果笔记本电脑
String macBrand = "MacBookAir";
double macSize = 13.3;
double macPrice = 6988.88;
String macConfig = "i5处理器4GB内存128G固态硬盘";
int macCount = 5;
// thinkpad笔记电脑
String thinkBrand = "Thinkpad";
double thinkSize = 14.0;
double thinkPrice = 5999.99;
String thinkConfig = "i5处理器4GB内存500GB硬盘";
int thinkCount = 10;
// ASUS_FL5800笔记本电脑
String asusBrand = "ASUS_FL5800";
double asusSize = 15.6;
double asusPrice = 4999.5;
String asusConfig = "i7处理器4GB内存128GB硬盘";
int asusCount = 18;
// 库存数总和
int kucun;
kucun = macCount + thinkCount + asusCount;
// 库存价格总和
double jine;
jine = macPrice * macCount + thinkPrice * thinkCount + asusPrice * asusCount;
// 打印出
System.out.println("-----------------------------------商城库存清单----------------------------------------");
System.out.println("品牌型号 " + "尺寸 " + "价格 "
+ "配置 " + "库存数");
System.out.println(macBrand + " " + macSize + " " + macPrice + " " + macConfig
+ " " + macCount);
System.out.println(thinkBrand + " " + thinkSize + " " + thinkPrice + " " + thinkConfig
+ " " + thinkCount);
System.out.println(asusBrand + " " + asusSize + " " + macPrice + " " + asusConfig
+ " " + asusCount);
System.out.println("--------------------------------------------------------------------------------------");
System.out.println("总库存数: " + kucun);
System.out.println("库存商品总金额:" + jine);
}
}
本文地址:https://blog.csdn.net/weixin_52164430/article/details/109789521