Skip to main content

#Logic How to convert String Characters lower to upper and upper to low...

How to convert String Characters.  lower to upper and upper to lower


How to Convert all the String character Upper and lower. If String character is lower than convert Upper If it is Upper than you have to convert a lower. I am going to introduce it is a very simple and easy way. String Conversion is very easy through the toUpperCase() and toLowerCase(); Method But I am going to do this Question without using the Inbuilt method in the class.

You have to do this Only For logical coding Question.


So, Finally, I am going to do this Question step-by-step if you want to watch videos than you can watch. In these videos, I discuss this question in a very simple and easy way.

  1. You have to take one class with the main method.   
            class Test{

                public static void main(){
                   //your logic
              }
         }


    2. After that you can start the Writing the Logic Make sure that you have knowledge for logic than only you can write the logic.
    
         import java.util.Scanner;
        class Test{

                public static void main(){
                   Scanner sc=new Scanner(System.in);
                    String name=sc.next();
                   //1.Method
                     String s=name.toLowerCase(name);  
                    if(name.equals(s)) {
                              s=s.toUpperCase();
                            System.out.println(s); 
                      }
                 else{
                             System.out.println(s);
                   }
              }
         }

 Convert Lowercase to Uppercase in java and Uppercase to Lowercase without using the built-in method?

Coding Part:

import java.util.*;

class Nit{

  public static void main(String args[]){ 

         Scanner sc=new Scanner(System.in);  

         String s=sc.next();   

         String s1="";

               System.out.println("Original:"+s);  

            for(int i=0;i<s.length();i++){    

             char ch=s.charAt(i);

int a=(int)ch;

if(a>=65&&a<=97){

              a=a+32;

  }

else{      

             a=a-32;

           }

          s1=s1+(char)a;

       }   

    System.out.println("Modified String:"+s1);
 }

}


Output:

prince

Original: prince

Modified String: PRINCE

Press any key to continue . . .

   
           

Comments

Post a Comment

Popular posts from this blog

Top 100 Logical Question in java | Written test exam question | Logical programming question paper in java to crack the written test exam.

                                  The written  test exam question     If you want to crack the written test exam like TCS , INFOSYS , and WIPRO than you want these questions. this question is very useful for you if you are in college. before any drive for MNC  company you are readily forgiven the exam of this company so, this is for you. This question is very useful for developing logical skills in the programming language. If you want to become a good logical and standard coder than definitely this video for you don't miss this question. As you know logic is the power of the world if you have logic you can solve and find the solution to any type of problem. So, just focus on the logic noting else.         List of Question :       1. Write a Java program to print 'Hello' on screen and then print your name on a separate line. ...

#loop #typesofloop What is loop | How to use loop | Type of loop | comp...

What is loop | Types of loop | When should you choose loop | when you decide to good for loop | What is the need of loop. If you want to know about the loop than learn to hear. I am going to introduce the loop. Q1.What is loop  Ans: Loop is a technique to execute a block of statements multiple times. we can if you want to execute the statement multiple times then keep this statement inside the loop. through the loop, we can reduce the length of the program and the complexity of the code. types of loop. Types of the loop:    Basically, the loop is two types of 1.exit control loop and the other one is 2.entery control loop    1.Exit control loop-        The loop which is control after execution than goes for the exit control loop.        like- do-while loop          class A{                     public static void main...