Titlecase Download

Christina Cacioppo

strings, variables, string manipulation Polish needed


Java lets you convert the letters of a String to uppercase and lowercase letters. Using those two methods, plus substring to slice and dice our strings, we can make all sorts of funny combinations.


Write a script that starts with a String variable called name that's equal to your name, written in lower case letters, and converts your name into "title case" and "swap case."

More tangibly, that means:

Value of name Title case Swap case
anthony Anthony aNTHONY
barbara Barbara bARBARA
christina Christina cHRISTINA
david David dAVID

Your program should work no matter what value name holds, which means you'll want to avoid replacing any pieces of the String. Instead, stick to the toUpperCase and toLowerCase, and substring methods.

Starter code

class Titlecase{
	public static void main(String[] args){
		String name = "firstname";

		//Your code below

Expected output

If your name were Eddie, your program should print:



Useful tools to solve the problem