Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement express delivery system based on java language

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to implement the express delivery system based on java language. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The details are as follows

Function introduction:

1. Role switching (couriers and ordinary users)

Courier: it has the functions of saving express delivery, deleting express delivery, modifying express delivery information, and viewing all express delivery.

Users: have the function of picking up express delivery

2. Express information must have company name, express order number and pickup code information.

Knowledge points involved:

1. Java basic syntax

2. Java basic data types

3. Process control statements (if, switch, while, do while, for, break and continue)

4. Array

Analysis.

1. The title requires the function of storing express delivery, so the company name array, express order number array and pick-up code array must be defined respectively in the design, which are represented by CompanyNameSource, NumberSource and CodeSource respectively. Of course, there needs to be an express subscript count, which is used to count the number of express deliveries.

2. In order to ensure that the user can continue to perform the next task after executing one task, I use the while (true) loop and add break at the end of each loop to ensure that it can be executed after completion.

To sum up, the planning algorithm and code:

The code is as follows:

Package com.kaikeba;import java.util.Scanner;public class demo1 {public static void main (String [] args) {/ / define the company name array String [] CompanyNameSource = new String [100]; / / define the express order number array int [] NumberSource = new int [100]; / / define the pickup code array int [] CodeSource = new int [100] / / define the odd subscript int count = 0; Scanner input = new Scanner (System.in); System.out.println ("= Welcome to the new vocational course express cabinet ="); while (true) {/ / while loop to ensure that the user can execute System.out.println after performing an operation ("Please enter your identity: 1-courier" 2-user "); int User = input.nextInt (); if (User = = 1) {System.out.println (" Please select operation: 1-Express input 2-Delete Express 3-modify Express 4-View all Express 5-exit the system "); int function = input.nextInt () If (function = = 1) {System.out.println ("Please enter the express order number:"); int Number = input.nextInt (); NumberSource [count] = Number; / / into the express order number array System.out.println ("Please enter the company name") String CompanyName = input.next (); CompanyNameSource [count] = CompanyName; / / deposited in the company name int code = (int) Math.round (Math.random () * 10000); System.out.println ("Express has been deposited, the pickup code is:" + code); CodeSource [count] = code / / deposit the express code count++;} else if (function = = 2) {System.out.println ("Please enter the express order number to be deleted:"); int Number = input.nextInt (); for (int I = 0; I

< NumberSource.length; i++) { if (NumberSource[i] == Number) { System.out.println("删除成功!"); break; } else { System.out.println("未找到快递!"); break; } } } else if (function == 3) { System.out.println("请输入要修改的快递单号"); int Number = input.nextInt(); for (int i = 0; i < NumberSource.length; i++) { if (NumberSource[i] == Number) { System.out.println("请输入新的快递单号:"); int NewNumber = input.nextInt(); NumberSource[i] = NewNumber; System.out.println("修改成功"); break; } else { System.out.println("未找到快递!"); break; } } } else if (function == 4) { System.out.println("所有快递信息如下:"); for (int i = 0; i < NumberSource.length; i++) { if (NumberSource[i] == 0) { System.out.println("无快递信息!"); break; } else { System.out.println("快递编号:" + NumberSource[i]); break; } } for (int i = 0; i < CompanyNameSource.length; i++) { if (CompanyNameSource[i] == null) { System.out.println("无快递公司信息!"); break; } else { System.out.println("快递编号:" + NumberSource[i]); break; } } for (int i = 0; i < CompanyNameSource.length; i++) { if (CompanyNameSource[i] == null) { System.out.println("无快递公司信息!"); break; } else { System.out.println("快递公司:" + CompanyNameSource[i]); break; } } } else if (function == 5) { System.out.println("谢谢使用!"); break; } } else {// 普通用户 System.out.println("请输入取件码:"); int code = input.nextInt(); for (int i = 0; i < CodeSource.length; i++) { if (CodeSource[i] == code) { System.out.println("取件成功!"); break; } else if (CodeSource[i] != code) { System.out.println("未找到该快递!"); break; } } } } }} 效果图: 初始界面(快递员和普通用户) 快递录入

Express deletion

-modify express delivery

Query all couriers

User (pickup)

Thank you for reading! This is the end of this article on "how to implement an express system based on java language". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report