I'm a newbie to Java, so I'm sorry if this is a silly question. I'll post the code first, then explain my problem.
import java.util.Scanner;
class CharacterOperations{
public void run(){
System.out.println("1. toUpper");
System.out.println("2. toLower");
System.out.println("3. Alphabet");
System.out.println("4. Quit");
int input;
Scanner sc = new Scanner(System.in);
input = sc.nextInt();
while (input == 1 || input == 2 || input == 3){
input = sc.nextInt();
if (input == 1){
System.out.println(toUpper());
}
}
}
public void toUpper(char lowerCase){
int decimal;
decimal = (int) lowerCase - 32;
if(decimal >= 65 && decimal <= 90){
System.out.println( (char) decimal);
}
}
public void toLower(char upperCase){
int decimal;
decimal = (int) upperCase + 32;
if(decimal >= 97 && decimal <= 122){
System.out.println( (char) decimal);
}
}
public void alphabet(char start, char end){
int decimalStart = (int) start;
int decimalEnd = (int) end;
while(decimalStart != decimalEnd){
if(( (int) start >= 65 && (int) start <= 90) && ( (int) end >= 97 && (int) end <= 122)){
decimalStart = (int) start + 32;
System.out.println( (char) decimalStart);
start++;
}
else if(( (int) start >= 97 && (int) start <= 122) && ( (int) end >= 65 && (int) end <= 90)){
decimalEnd = (int) end + 32;
end = (char) decimalEnd;
System.out.println( (char) decimalStart);
start++;
}
else {
decimalStart = (int) start;
System.out.println( (char) start);
start++;
}
}
}
}
When the user inputs 1, 2, or 3 into the terminal window, I want the run method to call the toUpper, toLower, or alphabet method, respectively. The methods work properly when selected from an object (I'm using BlueJ) but I can't seem to properly call the methods within the run method. As the code stand now, I get the following error when I try to compile: "toUpper(char) in CharacterOperations cannot be applied to ()". I can't use the class Character from the Java library, nor can the class contain properties.
Can anyone tell me what I'm doing wrong?