zoukankan      html  css  js  c++  java
  • 商品库存管理查看增减

    import java.util.Scanner;
    public class Shoppp{
        public static void main(String[] args){
        String[] storee=new String[]{"MacBookAir","ThinkpadT50"};
        double[] size={13.3,15.6};
        double[] price={9998.97,6789.56};
        int[] count={0,0};
        
        while(true){
            int ch = showT();
            switch(ch){
                case 1:
                showL(storee,size,price,count);//查看
                break;
                case 2:
                showC(count);//修改
                break;
                case 3:
                return;
                
                default:
                System.out.println("这不是指令");
                break;
            }
            
        }
            
        }
        //修改
        public static void showC(int[] counttt){
            System.out.println("输入1修改商品MacBookAir输入2修改商品ThinkpadT50");
            Scanner sc = new Scanner(System.in);
            while(true){
            if(sc.nextInt()==1){
                System.out.println("MacBookAir要修改成多少");
                Scanner scc = new Scanner(System.in);
                counttt[0]=scc.nextInt();
            }else{
                System.out.println("ThinkpadT50要修改成多少");
                Scanner sccc = new Scanner(System.in);
                counttt[1]=sccc.nextInt();
            }
            System.out.println("还要继续修改吗?1继续修改2退出");
            Scanner ss = new Scanner(System.in);
            if(ss.nextInt()==1){
            System.out.println("输入1修改商品MacBookAir输入2修改商品ThinkpadT50");
            }else{
            return;
            }
        }
        }
        //查看
        public static void showL(String[] storee,double[] size,double[] price,int[] count){
            System.out.println("--------商场库存清单--------");
            System.out.println("品牌名称"+"    "+"尺寸"+"    "+"价格"+"    "+"库存数");
            int countShop=0;//商品总数
            int countPrice=0;//商品总价
            //打印数组
            for(int i =0;i<storee.length;i++){
                System.out.println(storee[i]+"    "+size[i]+"    "+price[i]+"    "+count[i]);
                countShop+=count[i];
                countPrice+=count[i]*price[i];
            }
            System.out.println("总库存数:"+countShop);
            System.out.println("商品总金额:"+countPrice);
        }
        //
        public static int showT(){
            System.out.println("--------库存管理--------");
            System.out.println("1查看库存清单");
            System.out.println("2修改商品库存数量");
            System.out.println("3退出");
            System.out.println("请输入要执行的操作序号:");
            Scanner sc = new Scanner(System.in);
            return sc.nextInt();   //返回用户输入的序号
        }
    }
  • 相关阅读:
    关于git修改和查看用户名邮箱
    Spring深入理解(三)
    Spring深入理解(二)
    Spring深入理解(一)
    jeecg开源快速开发
    关于面向对象的三大特性和五大基本原则
    关于Excel导入导出POI工具类
    关于Hanoi算法
    LOJ 530 最小倍数(数论)
    BZOJ 4242 水壶(BFS建图+最小生成树+树上倍增)
  • 原文地址:https://www.cnblogs.com/xiandong/p/7867924.html
Copyright © 2011-2022 走看看