java 库存出入货物程序设计

此案例编写一个模拟商品入库的程序(里面包含 品牌型号,尺寸,价格,配置,库存,总价),在控制台输入数量,便可以得到商品的总价格。(这里华为,小米为示例)

此程序只有一个Test类

Test类

这里建议test1开头字母为大写

import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        //准备一些华为手机信息
       String huaWeiBrand="华为手机";
       double huaWeiSize=5.5;
       double huaWeiPrice=3688.88;
       String huaWeiConfig="8+128g 全面刘海屏";
        System.out.println("品牌:"+huaWeiBrand);
        System.out.println("尺寸:"+huaWeiSize);
        System.out.println("价格:"+huaWeiPrice);
        System.out.println("配置:"+huaWeiConfig);
        Scanner sc  = new Scanner(System.in);
        System.out.println("请输入"+huaWeiBrand+"的库存");
        int huaWeiCount = sc.nextInt();
        double huaWeiMoney=huaWeiCount*huaWeiPrice;
        System.out.println("库存"+huaWeiBrand+"的金额"+huaWeiMoney);

        //准备一些小米手机的信息
        String XMBrand="小米手机";
        double XMSize=5.0;
        double XMPrice=2988.88;
        String XMConfig="4+64g 全面屏";
        System.out.println("品牌:"+XMBrand);
        System.out.println("尺寸:"+XMSize);
        System.out.println("价格:"+XMPrice);
        System.out.println("配置:"+XMConfig);
        System.out.println("请输入"+XMBrand+"的库存");
        int XMCount = sc.nextInt();
        double XMMoney=XMCount*XMPrice;
        System.out.println("库存"+XMBrand+"的金额"+XMMoney);

        System.out.println("--------------库存清单----------------");
        //"\t"制表符 "\t"调整表格=tab键
        System.out.println("品牌型号\t 尺寸\t价格\t配置\t库存\t金额\t");
        System.out.println(huaWeiBrand+"\t"+huaWeiSize+"\t"+huaWeiPrice+"\t"+huaWeiConfig+"\t"+huaWeiCount+"\t"+huaWeiMoney);
        System.out.println(XMBrand+"\t"+XMSize+"\t"+XMPrice+"\t"+XMConfig+"\t"+XMCount+"\t"+XMMoney);
        System.out.println("-------------------------------------");
        System.out.println("总库存"+(huaWeiCount+XMCount));
        System.out.println("总金额"+(huaWeiMoney+XMMoney));

    }
    }

成果展示

库存清单这里如果觉得不太好看,可以在 代码中调节,添加制表符(因为本人太懒,所以不想调节了)。

  • 2
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浩气长存在心中

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值