Hey everybody,
I am having lots of trouble storing values in an array and I want to be prompt at the beginning of each value. The values I will enter will be two digit values such as 23, or 42, or 35.
Anyways, i am prompted but there is problem with my loop or (char) print statements but i cant get it to work!!!
This is my code:
Any help is very much appreciated!
Thanks,
Gabe
I am having lots of trouble storing values in an array and I want to be prompt at the beginning of each value. The values I will enter will be two digit values such as 23, or 42, or 35.
Anyways, i am prompted but there is problem with my loop or (char) print statements but i cant get it to work!!!
This is my code:
Code:
class prompt2 {
public static void main(String[] args)
throws java.io.IOException {
int p[] = new int[4];
for ( int i = 0; i < 4; i++)
{
System.out.println("Enter the distance from the center to point p" + i + ":\n");
p[i] = System.in.read() ;
System.out.println("The numbers in the array for p are: p0 is: " + p[0] + " p1 is: " + (char) p[1]+ " p2 is: " +
(char) p[2]+ " p3 is: " + (char) p[3]);
Any help is very much appreciated!
Thanks,
Gabe
Comment