Exercise: Character operations

Write a program that implements different methods which act on strings and characters:

Your program without methods can look like this:

String input = "Hello world!";
System.out.println("Upper case: " + stringToUpperCase(input));
System.out.println("Lower case: " + stringToLowerCase(input));
String toggled = toggleCase(input);
System.out.println("Toggled: " + toggled);

System.out.println("\"" + input + "\" and \"" + toggled + "\" are " +
    "equal (ignoring case): " + equalIgnoreCase(input, toggled));

String numberMaybe = "5801";
System.out.println(numberMaybe + " is a number: " + isNumber(numberMaybe));

String letters = "Abc Xyz";
int[] positionsInAlphabet = getPositionsInAlphabet(letters);
System.out.println("Positions in alphabet of \"" + letters + "\": " +
    toString(positionsInAlphabet));

Program output:

Upper case: HELLO WORLD!
Lower case: hello world!
Toggled: hELLO WORLD!
"Hello world!" and "hELLO WORLD!" are equal (ignoring case): True
5801 is a number: True
Positions in alphabet of "Abc Xyz": 0, 1, 2, -1, 23, 24, 25

Hints 💡

Hand in instructions

  1. Make sure your program runs correctly.
  2. Hand in your program by uploading Main.java to Moodle.