simple java question?
how do i handle input on an integer?
in this book my friend lent me, i read that i could use this and it would work.
import java.io.*;
public class RectDrawer
{
static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter screen = new PrintWriter(System.out,true);
public static void main(String[] args)
{
int i,j,rows,cols;
screen.println("Enter the dimension of the rectangle.");
screen.print("columns?"); screen.flush();
*cols = new Integer(keyboard.readLine()).intValue();
screen.print("rows?"); screen.flush();
*rows = new Integer(keyboard.readLine()).intValue();
screen.println("This will have three rows and three columns\n");
for (i=0;i<cols;i++) screen.print(" "+"_"); screen.println(" ");
for (j=0;j<rows;j++)
{
for (i=0;i<cols;i++) screen.print("|"+"_"); screen.println("|");
}
}
}
i put * on the lines im having trouble with. i get errors here:
Error: cannot resolve symbol
symbol : method intValue ()
location: class java.lang.String
and this one:
Error: unreported exception java.io.IOException; must be caught or declared to be thrown
argh. programming n00b. help me out.
|