Java- 专家术语学习机

如何工作

3组单字随机跳出来排列组合输出

  1. 创建3个String的数组,用于保存术语。
  2. 随机挑出单字。首先要知道数组的长度n,再根据数组长度,然后选出介于0~n-1的随机数,最后获得单字。
  3. 创建专用术语,选出3个字用“+”将字符串链接在一起。
  4. 最后输出结果。

代码

import static java.lang.Math.random;
public class PhraseOMatic {
    public static void main(String[] args) {
        // 可随意加入其它术语
        String[] wordListOne = { "24/7", "multiTier", "30,000 foot", "B-to-B", "win-win", "frontend", "web-based",
                "pervasive", "smart", "sixsigma", "critical-path", "dynamic" };
        String[] wordListTwo = { "empowered", "sticky", "value-added", "oriented", "centric", "distributed",
                "clustered", "branded", "outside-the-box", "positioned", "networked", "focused", "leveraged", "aligned",
                "targeted", "shared", "cooperative", "accelerated" };
        String[] wordListThree = { "process", "tippingpoint", "solution", "architecture", "core competency",
                "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission" };
        // 计算每一组有多少个名词
        int oneLength = wordListOne.length;
        int twoLength = wordListTwo.length;
        int threeLength = wordListThree.length;
        // 产生随机数字
        int rand1 = (int) (random() * oneLength);
        int rand2 = (int) (random() * twoLength);
        int rand3 = (int) (random() * threeLength);
        // 组合出专家术语
        String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
        // 输出
        System.out.println("What we need is a " + phrase);
    }
}

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

eeenkidu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值