Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Random Generating Number Problems

960425Sep 6 2012 — edited Sep 6 2012
I have been working on this random number generation game were you have to guess a number between 0-15 and it wont run please help me to see what is wrong with my code.


import java.until.Random;
import java.until.Scanner;

public class Main
{
public static void main(String[] args)
{
System.out.print("input Number:");

// Get number between 0-15
int in = getInput();

//Generate Random Number
int val = getRandomNumber();

//Test if numbers are the same
if (in == val)
System.out.println("We Win");
else
System.out.println("We Lose");

System.out.println("our number:" + in);
System.out.println("Computers Number:" + val);



}

public static int getInput();
{
Scanner scan = new Scanner(System.in);

String temp = scan.next();

int res = Integer.parseInt(temp);

if (res < 0)
res=0;
if (res > 15)
res=15;

return res;
}


public static int `()
{
Random rand = new Random();

int res = rand.nextInt (16);

return res;
}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2012
Added on Sep 6 2012
7 comments
229 views