Java Case Example Commodity inventory management system

Source: Internet
Author: User

Today, according to the code of the teacher to read and write a product inventory management system:

The code is as follows

/*
Achieve inventory management of commodities
Function:
1. Display User Selection Function list
2. Perform different operations according to the selected function number
A. Show all Inventory
B. Modifying inventory quantities

Analysis:
1. Display user list:
Output statement, user input, select function serial number
2. Depending on the selection, call different methods
Switch statement
Case 1 2 3
A Display Inventory
Will store an array of goods, traverse
B Modify Inventory

To modify all inventory quantities
*/
Guide Package
Import Java.util.Scanner;
public class shopping{
public static void Main (string[] args) {
Depositing basic data information into an array
String[] Pinpai = {"Macbookair", "Thinkpa450", "EatpadT897"};
double[] size = {13.3,15.6,25.6};
Double[] Price = {2567.9,4562.8,9999.6};
Int[] count = {0,0,0};
while (true) {
int choose = Choosefunction ();
Switch (choose) {
View inventory List
Case 1:checkbox (Pinpai,size,price,count);
Break
Modifying inventory data
Case 2:update (Pinpai,count);
Break
Case 3:return;
DEFAULT:SYSTEM.OUT.PRINTLN ("incorrect input");
}
}
}
Show access to the action list interface
public static int choosefunction () {
System.out.println ("----------Inventory Management----------");
System.out.println ("1. View inventory list");
System.out.println ("2. Change the quantity of goods in stock");
System.out.println ("3. Exit");
System.out.println ("Please enter the number of actions to be performed:");
Receiving operation signal from user input
Scanner sc = new Scanner (system.in);
int choosenumber = Sc.nextint ();
Returns the operation signal entered by the user
return choosenumber;
}
View the Inventory List interface
public static void CheckBox (string[] pinpai,double[] size,double[] price,int[] count) {
System.out.println ("----------Store stock list----------");
SYSTEM.OUT.PRINTLN ("Brand model size price Stock Number");
Double totalprice = 0.0;
int totalcount = 0;
for (int i=0;i<pinpai.length;i++) {
System.out.println (pinpai[i]+ "" +size[i]+ "" +price[i]+ "" +count[i]);
Totalprice + = Price[i];
TotalCount + = Count[i];
}
SYSTEM.OUT.PRINTLN ("Total number of stocks" +totalcount);
System.out.println ("The total amount of commodity inventory is" +totalprice);
}
Modify the inventory information interface
public static void UpDate (string[] pinpai,int[] count) {
Scanner sc = new Scanner (system.in);
for (int i=0;i<pinpai.length;i++) {
System.out.println ("Please enter the stock number of the brand" +pinpai[i]+ ");
int n = sc.nextint ();
Count[i] = n;
}
}
}

Java Case Example Commodity inventory management system

Related Article

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.