首页 > 其他 > 详细

商品库存管理查看增减

时间:2017-11-20 21:26:19      阅读:279      评论:0      收藏:0      [点我收藏+]
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();   //返回用户输入的序号
    }
}

商品库存管理查看增减

原文:http://www.cnblogs.com/xiandong/p/7867924.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!