The simplest inventory Management Java case

Source: Internet
Author: User

 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.