Created
February 2, 2022 06:56
-
-
Save DevAmiyo/b710f8410e2a1c2f1aa2e9dd7fa6dab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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