For this piece of code I have to change the arguments in the writeLine and writeBlock methods to char c, instead of String c. The problem is I dont know how to get the scanner to read in a character instead of a string. Is there any way to go about doing this and changing String c to char c in the writeLine and writeBlock methods?
public static void writeLine(String c, int n)
{
if(n==0){
System.out.println();
return;
}
else{
System.out.print(c);
}writeLine(c, n-1);
}
public static String writeBlock(String c, int m, int n)
{
if (m==0){
System.out.println();
return "";}
else{
writeLine(c, n);
return (writeBlock(c, m-1, n));
}
}
public static void main(String[] args)
{
int n;
int m;
String c;
Scanner sc = new Scanner(System.in);
System.out.println("input a character and two integers: ");
//get the values
c=sc.next();
n=sc.nextInt();
m=sc.nextInt();
c.charAt(0);
System.out.println(writeBlock(c, m, n));
}
}