[QUOTE=Skeim;110441]as far as I understand u want it to calculate the numbers again if the user types "y", so u just have to suround it all with a while loop, not just slot1. slot2 and slot3, then it will calculate the random numbers until the user write something else than "y" . And u must use the Scanner reference, keyboard to scan the next word, or line, keyboard.nextline() .
like this:
[code=java]
import java.util.Scanner;
public class HW10 {
public static void main(String[] args)
{
//Declares variables
String another = "y";
int slot1;
int slot2 = 0;
int slot3;
while(another.equalsIgnoreCase("y")) {
//This header explains what the program does
System.out.println("This program randomly generates a number between 1 and 10");
//Ask the use to input a yes or a no.
Scanner keyboard = new Scanner (System.in);
System.out.print("Would you like to continue y or n:");
another = keyboard.nextLine();
//Add comments
slot1 = (int) (Math.random() *(10));
slot2 = (int) (Math.random() *(10));
slot3 =(int) (Math.random() *(10));
slot1 = slot2 = slot3 = slot2;
}
}
}
Awesome thanks! I I also had to print out the number it generated but that was easy and its working now!