Java Basics: Why won't this return a character from the ASCII table?
807580Dec 20 2009 — edited Dec 20 2009Hello all,
I am working on a project. Right now I am in stage one of development, and already I have fallen into a dilemma. I cannot figure out why this code will not return a character value. If you look closely, I am trying to generate a random number from 65 to 90, and then convert that number to the proper ASCII character. Let me know your thoughts, thanks!
import java.util.*;
import java.lang.*;
class Liscense
{
public static int Randomchar()
{
int charFive = 65 + (int) (Math.random()*90);
return (char) charFive;
}
public static void main (String [] args)
{
double y = Math.random()*1000;
double x = Math.random()*1000;
System.out.println(("x: ") + y);
System.out.println(("y: ") + x);
System.out.println(Randomchar());
System.out.println(x + y);
}
}