第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);
	}
	
	
}

在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值