In: Computer Science
In a file called FourCapitalizations.java, write a program that:
For example: if the user enters string "gaNDalF12 !! AB3w", your program output should look EXACTLY like this:
Please enter a string: gaNDalF12 !! AB3w 1st version: gaNDalF12 !! AB3w 2nd version: GANDALF12 !! AB3W 3rd version: gandalf12 !! ab3w 4th version: Gandalf12 !! ab3w
import java.util.Arrays;
import java.util.Scanner;
public class FourCapitalizations {
public static void main (String args[])
{
double sum=0;
Scanner sc = new
Scanner (System.in);
System.out.print("Please enter a string: ");
String
str=sc.nextLine();
System.out.println("1st version: "+str);
System.out.println("2nd version: "+str.toUpperCase());
System.out.println("1st version: "+str.toLowerCase());
//captipal first character
String cap =
str.substring(0, 1).toUpperCase() + str.substring(1);
System.out.println("1st version: "+cap);
}
}