首页 > 代码库 > 练习:专家术语学习机
练习:专家术语学习机
1 package com.hfjava5; 2 3 public class PhraseOMatic { 4 public static void main(String[] args) { 5 String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B", 6 "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma", 7 "critical-path", "dynamic"}; 8 String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", 9 "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", 10 "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};11 String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency",12 "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};13 14 // 计算每一组有多少个名词术语15 int oneLength = wordListOne.length; // 1216 int twoLength = wordListTwo.length; // 1817 int threeLength = wordListThree.length; // 1218 19 /* Java本身有一组立即可用的数学方法20 * random()会返回介于0与1之间的值,所以需要将此值乘以数组的元素数量(数组的大小),然后取*整数值*(第4章)21 * 如果需要对任何浮点数取整数值也是用这样的方法转换数据类型22 */23 // 产生随机数字24 int rand1 = (int) (Math.random() * oneLength); // 0-1225 int rand2 = (int) (Math.random() * twoLength); // 0-18 26 int rand3 = (int) (Math.random() * threeLength); // 0-1227 28 // 组合出专家术语29 String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];30 31 System.out.println("What we need is a " + phrase);32 }33 }
练习:专家术语学习机
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。