I have read the other questions with the same title but none have helped with my issue and nothing online has helped either.
I am new to Java and am trying to get a basic program running but I keep getting the aforementioned error.
Code below.
package loopy;
import java.io.*;
public class loopy {
public static void main (String[] args) {
// TODO: Use a loop to print every upper case letter
for (int i = 65; i < 91; i++) {
System.out.println((char)i);
}
// TODO: Get input from user. Print the same input back but with cases swapped.
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
String input = in.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
toggleStringCase(input);
}
// TODO: Implement this function to return the opposite case of the letter given. DO NOT USE any built in functions.
// How to handle the case where the char given is not a letter?
private static char toggleCase(char c) {
return c;
}
// TODO: Implement this function to toggle the case each char in a string. Use toggleCase() to help you.
private static String toggleStringCase(String str) {
return str;
}
}
Where it says toggleStringCase(input); is where I am getting the error trying to pass the variable to a function.
Nothing i have read suggests what I might be doing wrong.
I am sure it must be a basic error but could someone please point me in the right direction.
Have I missed some syntax somewhere?