public class PhraseOMatic{
public static void main(String [] args ) {
String[] stat1={"matt","john","harry","mary"};
String[] stat2={"is getting","works like","is"};
String[] stat3={"mad","crazy","smart"};
//size of each array
int len1=stat1.length;
int len2=stat2.length;
int len3=stat3.length;
//pick a random word from each statement
int rand1= (int) (Math.random() * len1);
int rand2= (int) (Math.random() * len2);
int rand3= (int) (Math.random() * len3);
//make a phrase
String phrase = stat1[rand1]+ " " + stat2[rand2] + " "
+ stat3[rand3];
//print
System.out.print("Statement: " + phrase);
}
}
No comments:
Post a Comment