Skip to content

Instantly share code, notes, and snippets.

@DevAmiyo
Created February 2, 2022 06:56
Show Gist options
  • Save DevAmiyo/b710f8410e2a1c2f1aa2e9dd7fa6dab7 to your computer and use it in GitHub Desktop.
Save DevAmiyo/b710f8410e2a1c2f1aa2e9dd7fa6dab7 to your computer and use it in GitHub Desktop.
import java.util.*;
public class styleText {
public static void main(String[] args) {
Scanner userinput = new Scanner(System.in);
System.out.print("Enter a sentence: ");
String sentence = userinput.nextLine();
System.out.print("Stylized Sentence: ");
char a = ' '; int b = 0;
for (int i = 0; i < sentence.length(); i++) {
a = sentence.charAt(i);
if (a != ' ') {
if (b % 2 != 0)
a = Character.toLowerCase(a);
else
a = Character.toUpperCase(a);
b++;
}
else
b += 2;
System.out.print(a);
}
System.out.println("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment