第3章 商城库存清单

/*
	实现商品库存清单案例
	步骤:
		1.实现表头,是固定数据,直接写出输出语句
		2.表格中间,商品数据,采用变量形式,定义变量,找对数据类型,输出所有变量
		3.表格尾部,一部分数据固定,另一部分,商品数据进行数学计算		
*/
public class  Shopp1{
	public static void main(String[] args){
		//1.输出表头固定数据
		System.out.println("----------------商场库存清单----------------");
		System.out.println("品牌型号       尺寸       价格       库存数");
		
		//2.表格中间,商品数据,采用变量形式,定义变量,找对数据类型,输出所有变量
		//定义表格中的数据变量
		//品牌型号:String 尺寸:double 价格:double 库存:int
		String macBrand = "MacBookAir";
		double macSize = 13.3;
		double macPrice = 6988.88;
		int    macCount = 5;
		
		String thinkBrand = "ThinkPadT450";
		double thinkSize  = 14;
		double thinkPrice = 5999.99;
		int    thinkCount = 10;
		
		String asusBrand = "AUS-FL5800";
		double asusSize  = 15.6;
		double asusPrice = 4999.5;
		int    asusCount = 18;
		//商品信息变量打印,变量之间加入一定的字符串空格
		System.out.println(macBrand + "     " + macSize + "       " + macPrice + "     " + macCount);
		System.out.println(thinkBrand + "   " + thinkSize + "       " + thinkPrice + "    " + thinkCount);
		System.out.println(asusBrand + "     " + asusSize + "       " + asusPrice + "     " + asusCount);
		System.out.println("--------------------------------------------");
		//3.表格尾部,一部分数据固定,另一部分,商品数据进行数学计算
		int totalCount = macCount + thinkCount + asusCount;
		double totalPrice = macCount * macPrice + thinkCount * thinkPrice + asusCount * asusPrice;
		System.out.println("总库存数:" + totalCount);
		System.out.println("库存商品总金额:" + totalPrice);
	}
	
	
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_40807247/article/details/82991787
今日推荐