zoukankan      html  css  js  c++  java
  • Java手机库存清单

    import java.util.Scanner;
    public class KuCun{
    public static void main(String[] args){
    System.out.println("------------------手机库存清单--------------------");
    System.out.println("品牌 尺寸 价格 库存数");
    while(true){
    System.out.println("1:显示手机库存清单;2:退出");
    Scanner input=new Scanner(System.in);
    int num=input.nextInt();
    switch(num){
    case 1:
    show();
    break;
    case 2:
    System.out.println("退出");
    break;
    default:
    System.out.println("输入1或2");
    }
    if(num==2){
    break;
    }
    }
    }
    public static void show(){
    String miPhone="mi8";
    double miSize=4.6;
    int miPrice=2599;
    int miCount=100;

    String hoPhone="ho10";
    double hoSize=5.2;
    int hoPrice=2399;
    int hoCount=1000;

    String opPhone="opR17";
    double opSize=5.6;
    int opPrice=2999;
    int opCount=10000;

    System.out.println(miPhone+" "+miSize+" "+miPrice+" "+miCount);
    System.out.println(hoPhone+" "+hoSize+" "+hoPrice+" "+hoCount);
    System.out.println(opPhone+" "+opSize+" "+opPrice+" "+opCount);

    int totalCount=miCount+hoCount+opCount;
    long totalMoney=(long)(miCount*miSize+hoCount*hoSize+opCount*opSize);

    System.out.println("总库存数"+totalCount);
    System.out.println("总金额"+totalMoney);
    }

    }

  • 相关阅读:
    java回顾之多线程
    java回顾之异常
    模拟斗地主和冒泡排序
    java回顾之Map
    java回顾之集合List
    java回顾之树
    java回顾之单列集合、泛型、数据结构
    java回顾之类API再体验之引用类型小结
    java回顾之API初体验
    函数之 闭包函数 和 装饰器
  • 原文地址:https://www.cnblogs.com/WLeon/p/10297490.html
Copyright © 2011-2022 走看看