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);
}

}

原文地址:https://www.cnblogs.com/WLeon/p/10297490.html