Created
May 5, 2018 08:44
-
-
Save PandyYang/16e631097fcb4b6a935acae82c2fc1db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package justdo; | |
import java.util.*; | |
/** | |
* @author Pandy | |
* @date 2018/5/5 11:12 | |
*/ | |
public class GoodsManager { | |
public static void main(String[] args) { | |
String[] brand = {"Lenove","ThinkPad","Apple"}; | |
double size[] = {5.99,6.00,5}; | |
double price[] = {999,888,666}; | |
int count[] = {10,10,10}; | |
while(true){ | |
printSystem(); | |
int num = new Scanner(System.in).nextInt(); | |
switch(num){ | |
case 1: | |
System.out.println("商品总目目录如下:"); | |
printGoods(brand,size,price,count); | |
break; | |
case 2: | |
System.out.println("修改"); | |
changeCoods(brand,count); | |
break; | |
case 3: | |
System.out.println("退出程序"); | |
return; | |
default: | |
System.out.println("您输入的序号有误!请重新输入!"); | |
} | |
} | |
} | |
public static void printGoods(String[] brand,double[] size,double[] price,int[] count){ | |
int allMoney = 0; | |
int allCount = 0; | |
System.out.println("商标" + " " + "尺寸" + " " + "价格" + " " + "数量"); | |
for (int i = 0;i<brand.length;i++){ | |
System.out.println(brand[i] + " " + size[i] + " " +price[i] + " " +count[i] + "\t"); | |
allMoney += count[i]*price[i]; | |
allCount += count[i]; | |
} | |
System.out.println("============================"); | |
System.out.println("总数量:" + allCount); | |
System.out.println("总金额:" + allMoney); | |
} | |
public static void changeCoods(String[] brand,int[] count){ | |
for (int i = 0;i<brand.length;i++){ | |
System.out.println("请输入" + brand[i] + "的数量"); | |
Scanner scan = new Scanner(System.in); | |
int newCount = scan.nextInt(); | |
count[i] = newCount; | |
} | |
} | |
//public | |
public static void printSystem(){ | |
System.out.println("======================"); | |
System.out.println("1.查询总的商品目录"); | |
System.out.println("2.修改商品目录"); | |
System.out.println("3.退出程序"); | |
System.out.println("请输入要选择的序号:"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment