Computer Science, asked by marinanoel237, 3 months ago

Write a program to accept a string and change the case of each character of the string and display the new string Sample input: Welcome To School Sample output: wELCOME tO School​

Answers

Answered by tibrewalparth5
2

Explanation:

import java.io.*;

public class questionFIVE2008

{

    public static void main(String args[]) throws IOException

    {

        int ch;

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        System.out.println("ENTER THE STRING ");

        String input=br.readLine();

        int len=input.length();

        int i;

        for(i=0; i<len; i++)

        {

            ch=input.charAt(i);

            if(ch>=65 && ch<=90)

            {

                ch=ch+32;

                System.out.print((char)ch);

            }

            else if(ch>=97 && ch<=122)

            {

                ch=ch-32;

                System.out.print((char)ch);

            }

            else

            {

                System.out.print((char)ch);

            }

        }

    }

}

Similar questions