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();   //返回用户输入的序号
        }
    }
  • 相关阅读:
    django学习----http协议
    线程进程和协程
    内置函数
    我所了解的递归
    函数的闭包和装饰器
    字符串的内置方法
    格式化输入输出
    逻辑运算符和操作运算符
    python流程控制
    计算机网络原理
  • 原文地址:https://www.cnblogs.com/xiandong/p/7867924.html
Copyright © 2011-2022 走看看