Sinisterly
PhraseOmatic - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Java, JVM, & JRE (https://sinister.li/Forum-Java-JVM-JRE)
+--- Thread: PhraseOmatic (/Thread-PhraseOmatic)



PhraseOmatic - cervito21 - 03-06-2014

Code:
public class PhraseOMatic { public static void main (String[] args) { String[] ListOne = {"24/7", "multi-tier", "30,OOO foot", "B-to-B" , "win-win" , "frontend", "web- based" , "pervasive", "smart", "sixsigma", "critical-path", "dynamic"}; String[] ListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed", "clustered", "branded", "outaide-the-box", "positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"}; String[] ListThree = {"process", "tipping-point", "solution", "architecture", "core competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "session"}; // find out how many words are in each list int oneLenqth = ListOne.length; int twoLength = ListTwo.length; int threeLength = ListThree.length; // generate .... random numbers int randl = (int) (Math.random() * oneLenqth); int rand2 = (int) (Math.random() * twoLength); int rand3 = (int) (Math.random() * threeLength); //now build a phrase String phrase = ListOne[randl] + " " + ListTwo[rand2] + " " + ListThree[rand3]; // print out the phrase System.out.println("What we need is a " + phrase); } }



RE: PhraseOmatic - Deque - 03-06-2014

Interesting idea.
You should include some indentation. Without it is hard to read.
And since you want random integers, use new Random().nextInt(n) instead of Math.random(n). It will be better readable, no need for casting and the distribution is not biased.