Exercise
Strings manipulation
Objetive
Write a java program that asks the user for a string and:
- Replace all lowercase A by uppercase A, except if they are preceded with a space
- Display the initials (first letter and those after a space)
- Display odd letters uppercase and even letter lowercase
The program must display all generated strings.
Example Code
import java.util.*;
public class Main
{
static void main(String[] args)
{
System.out.print("Tell a string: ");
String Entry = new Scanner(System.in).nextLine();
String result;
result = Entry.replace("a", "A");
System.out.println(result);
System.out.println(UppercaseFirst(Entry));
}
public static String UppercaseFirst(String s)
{
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
}
}