Packagecom.tedu.day05;ImportJava.util.Scanner; Public classDemo {/*** There are 3 things the administrator can do (view, modify, exit) and we can do it using the (switch) menu. *-------------Inventory Management------------* 1. View inventory * 2. Modify Item Stock quantity * 3. Exit Please enter the number of actions to be performed: * Each feature operation, we use the method of encapsulation, so that the readability of the program can be enhanced. * Select "1. View inventory" function, then the console prints inventory list * Select "2. Modify Item Inventory Quantity" feature to update each item stock Number * Select "3. Exit" function, exit inventory management, end of program */ Public Static voidMain (string[] args) {string[] brand= {"MacBook", "ThinkPad"}; Double[] size = {13.3,14.7}; Double[] Price = {7988.88,6999.88}; int[] Count = {0,0}; while(true) {printmenu (); System.out.println ("Please enter menu options:"); Scanner Scan=NewScanner (system.in); intNumber =Scan.nextint (); Switch(number) { Case1: Printstock (brand, size, price, count); Break; Case2: Altercount (brand, count); Break; Case3: System.out.println ("Great place to stay!" "); return; default: System.out.println ("Input format or character error, please re-enter"); } } } //array traversal How to view inventory Public Static voidPrintstock (string[] brand,Double[] Size,Double[] Price,int[] count) { intTotalCount = 0; DoubleTotalprice = 0; System.out.println ("--------Inventory Management--------"); System.out.println ("Name----------size----------Price----------Quantity"); for(inti=0;i<brand.length;i++) {System.out.println (Brand[i]+ "------" +size[i]+ "---------" +price[i]+ "------" +count[i]+ "\ T"); TotalCount+=Count[i]; Totalprice= count[i]*Price[i]; } System.out.println ("----------------------------"); System.out.println ("Total Inventory:" +totalcount); System.out.println ("Total inventory Amount:" +totalprice); } //How to modify commodity inventory Public Static voidAltercount (string[] brand,int[] count) { for(inti=0;i<count.length;i++) {System.out.println ("Please enter the number of" +brand[i]+ "); Scanner Scan=NewScanner (system.in); intNewcount =Scan.nextint (); Count[i]=Newcount; } } //ways to display the function menu Public Static voidPrintmenu () {System.out.println ("1. View inventory List"); System.out.println ("2. Modify Inventory Quantity"); System.out.println ("3. Exit"); }}
function can also expand ...
The simplest inventory Management Java case