Do you know why I'm getting "cannot find symbol" error?
Anybody have any ideas on what I'm doing wrong here?
I made a program that prints out a square of asterisks. Now I need to modify it so the square is printed using whatever character a user types in when prompted. My assignment specifies that I need to use the statement "char fill = input.next().charAt(0)" to read the character from the user. I must have used that statement incorrectly though, because jgrasp keeps highlighting it and saying "cannot find symbol."
Can anyone help?
Code:
import java.util.Scanner;
public class parameterAssignment
{
//Main method begins execution of Java program
public static void main( String[] args )
{
//We will be using information typed in by keyboard
Scanner keyboard = new Scanner (System.in);
//Ask user for input
System.out.print(" We're going to make a square.\n How many units wide would you like it to be? ");
int side = keyboard.nextInt();
System.out.print(" We'll make the square out of a character of your choosing. \nPlease enter any one character on the keyboard. ");
char fill = input.next().charAt( 0 );
squareOfAsterisks(side, fill);
}//end main
public static void squareOfAsterisks(int side, char fill)
{
for (int i=1;i<=side;i++)/*declare and initialze control
variable; set loop continuation condition; increment control
variable by 1*/
{
for (int j=1;j<=side;j++)/*declare and initialze control
variable; set loop continuation condition; increment control
variable by 1*/
{
System.out.print(fill);
}
System.out.println();
}
}
}//end class squareOfAsterisks