ToggleCase is text that is converted to mixed case version of the text using looping and if statement. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of times. The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false. The Using ASCII Numbers convert the string into Capitalized Each Word. There are 128 standard ASCII characters, numbered from 0 to 127. Extended ASCII adds another 128 values and goes to 255.
Example :
Input : Tutor Joes
Output : tUTOR jOES
public class toogle { public static void main(String args[]) { //Program convert the given string into tOGGLE cASE wORD StringBuilder a = new StringBuilder("Tutor Joes Computer Education"); System.out.println("Original String : "+a); for (int i = 0; i < a.length(); i++) { if (a.charAt(i) >= 97 && a.charAt(i) <= 122) { int c = (int) a.charAt(i) - 32; a.setCharAt(i, (char) c); } else if (a.charAt(i) >= 65 && a.charAt(i) <= 90) { int c = (int) a.charAt(i) + 32; a.setCharAt(i, (char) c); } } System.out.println("tOGGLE cASE wORD Output : "+a); } }
Original String : Tutor Joes Computer Education tOGGLE cASE wORD Output : tUTOR jOES cOMPUTER eDUCATIONTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions