帮我写一个模拟生成公司数据的java脚本
时间: 2024-05-10 15:15:30 浏览: 16
好的,以下是一个简单的Java脚本,用于模拟生成公司数据:
```java
import java.util.Random;
public class CompanyGenerator {
private static final String[] COMPANY_NAMES = {"ABC Inc.", "XYZ Corp.", "123 Enterprises", "Acme Co.", "Global Solutions"};
private static final String[] INDUSTRIES = {"Technology", "Finance", "Manufacturing", "Healthcare", "Retail"};
private static final String[] LOCATIONS = {"New York", "London", "Tokyo", "Sydney", "Singapore"};
private static final String[] OWNERS = {"John Smith", "Mary Johnson", "David Lee", "Karen Chen", "Michael Brown"};
public static void main(String[] args) {
Random random = new Random();
for (int i = 0; i < 10; i++) {
String name = COMPANY_NAMES[random.nextInt(COMPANY_NAMES.length)];
String industry = INDUSTRIES[random.nextInt(INDUSTRIES.length)];
String location = LOCATIONS[random.nextInt(LOCATIONS.length)];
String owner = OWNERS[random.nextInt(OWNERS.length)];
int revenue = random.nextInt(1000000) + 100000;
int employees = random.nextInt(500) + 10;
System.out.println("Company name: " + name);
System.out.println("Industry: " + industry);
System.out.println("Location: " + location);
System.out.println("Owner: " + owner);
System.out.println("Annual revenue: $" + revenue);
System.out.println("Number of employees: " + employees);
System.out.println();
}
}
}
```
这个脚本会生成10个随机公司的数据,包括公司名称、行业、地点、所有者、年收入和员工人数。你可以根据需要修改这些数据。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)