Hello everyone...
yesterday I had task to draw a square by (*)
this is the way I done it.
yesterday I had task to draw a square by (*)
this is the way I done it.
import java.util.Scanner;
public class drawS{
public static void main(String[]args){
Scanner ask = new Scanner(System.in);
int length = ask.nextInt();
int i;
drowLine(length);
System.out.println();
for (i=0;i<length-2;i++){
drowEmptyLine(length);
System.out.println();
}
drowLine(length);
}
public static void drowLine(int n){
for (int i=0;i<n;i++){
System.out.print('*');
}
}
public static void drowEmptyLine(int n){
System.out.print('*');
for(int i=0; i< n-2; i++){
System.out.print(" ");
}
System.out.print('*');
}
}
The the teacher asked us to make the user choose the symbol to draw the square..
Here is my try but I faced some problems
Here is my try but I faced some problems
import java.util.Scanner;
public class anySymbol{
public static void main(String[]args){
Scanner ask = new Scanner(System.in);
System.out.println("Enter Symbol");
String Letter= in.nextLine();
System.out.println("Enter Length");
int length = ask.nextInt();
int i;
drowLine(length);
System.out.println();
for (i=0; i<length-2 ;i++){
drowEmptyLine(length);
System.out.println();
}
drowLine(length);
}
public static void drowLine(int n){
String Symbol = in.nextLine();
for (int i=0;i<n;i++){
System.out.print(Symbol);
}
}
public static void drowEmptyLine(int n){
String Symbol = in.nextLine();
System.out.print(Symbol);
for(int i=0; i< n-2; i++){
System.out.print(" ");
}
System.out.print(Symbol);
}
}
this is the error :
3 errors found:
[line: 8]
cannot find symbol
symbol : variable in
[line: 25]
cannot find symbol
symbol : variable in
location: class anySymbol
[line: 33]
cannot find symbol
symbol : variable in
location: class anySymbol
3 errors found:
[line: 8]
cannot find symbol
symbol : variable in
[line: 25]
cannot find symbol
symbol : variable in
location: class anySymbol
[line: 33]
cannot find symbol
symbol : variable in
location: class anySymbol
This post has been edited by PureLily: 08 May 2011 - 03:46 AM

New Topic/Question
Reply



MultiQuote







|