Java(命令行)打印库存清单
public class demo{ public static void main(String[] args){ //1 顶部 System.out.println("----------------商城库存清单------------------------------------------------"); System.out.println("品牌 尺寸 价格 库存数量"); //2 品牌 String macBrand = "MacBookAir"; double macSize = 15.6; double macPrice = 9888.3; int maccount = 6; String ThinkBrand = "ThinkPadT450"; double ThinkSize = 15.6; double ThinkPrice = 19888.3; int thinkcount = 2; String MiBrand = "ThinkPadT450"; double MiSize = 15.6; double MiPrice = 19888.3; int Micount = 10; //3 打印中部 System.out.println(macBrand+" "+macSize+" "+macPrice+" "+maccount); System.out.println(ThinkBrand+" "+ThinkSize+" "+ThinkPrice+" "+thinkcount); System.out.println(MiBrand+" "+MiSize+" "+MiPrice+" "+Micount); int total = maccount+thinkcount+Micount; double totalPrice = maccount*macPrice+ThinkPrice*thinkcount+Micount*MiPrice; //4 打印底部 System.out.println("库存总数"+total); System.out.println("库存总价格"+totalPrice);
}