I know hardly anything about Java, but there is this script, that I cannot release, that I need to add a random to for a friend. I offered to do it so I could learn Here is what I need (in psuedo code) Some Number between 1 and 10 Randomized case 0: number = 1 so "This text appears" case 1: number = 2 so "This text will appear" So basically a number between 1 and 10 (including 1 and 10) are randomized and assigned a case number (0-9) And if that number is randomly chosen, it will choose that case number and display the assigned text. I can clarify more, possibly, I'm not to sure, its hard to lay ideas from my mind into words =]
Assuming that you really are White and Ben Affleck you should know this stuff... Anyhow this works fine, wrote it a min ago and tested it... Code: EDIT: Commented it for you if that was required. Code: import java.util.*; public class Rand { /** Method to Return a Random integer Data Value. @param Value to Generate Random Integers to. @return The Random Data Value. */ public static int getRandom(int n) { Random gen = new Random(); return gen.nextInt(n) + 1; } public static void main(String[] agr){ // An integer named number. int number; /* * Generates a Random Number from 1 to the number stated * and stores it in the integer number. */ number = getRandom(10); /* Prints out what the Random Number is to make sure * the Case listed below matches the number. Can be changed * to any statement of chosing. */ System.out.println("The Random Number is: " + number); /* * Takes the Number and all of the cases of the number * in this Case it is from 1 to 10 and each case * displays a certain message. It can be used to display * as many Cases as you desire. */ switch (number) { case 1: System.out.println("Case if Number = 1"); break; case 2: System.out.println("Case if Number = 2"); break; case 3: System.out.println("Case if Number = 3"); break; case 4: System.out.println("Case if Number = 4"); break; case 5: System.out.println("Case if Number = 5"); break; case 6: System.out.println("Case if Number = 6"); break; case 7: System.out.println("Case if Number = 7"); break; case 8: System.out.println("Case if Number = 8"); break; case 9: System.out.println("Case if Number = 9"); break; case 10: System.out.println("Case if Number = 10"); break; } } } That will be 1,000 Credits Sir Enjoy. Zain.