The method toUpper has a parameter, when you call the method you are not sending it a parameter. Line 18 is where you call the toUpper method.
This is how is should look.
toUpper('a');
The reason why I took the System.out.println out of the code is because the method is void, which means it doesn't return anything that can be printed out. And because there is a print statement in the method.
Mattox
Junior Poster in Training
57 posts since Jan 2011
Reputation Points: 10
Solved Threads: 15
No problem, Do you need to read in a char from the user?
Mattox
Junior Poster in Training
57 posts since Jan 2011
Reputation Points: 10
Solved Threads: 15
You can use the scanner to read in a char,
import java.util.*;
public class readInChar
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
String s;
char u;
System.out.println("Enter you char: ");
s = scan.next();
u = s.charAt(0);
System.out.println(u);
}
}
scan.next() returns a String, that's why I used the charAt(0) method. The 0 in this method refers to the first element in the String.
Include reading in the userChar in the while loop and send that a parameter in the method calls and you should be good to go.
Mattox
Junior Poster in Training
57 posts since Jan 2011
Reputation Points: 10
Solved Threads: 15
Mattox
Junior Poster in Training
57 posts since Jan 2011
Reputation Points: 10
Solved Threads: 15