Header Ads

WAP to input a string and print the string input by user in upper case

 Example:-

Input : welcome to school
Output : WELCOME TO SCHOOL

Approach :

We will be using 'toUpperCase()' method to convert lowercase string to uppercase. 
Take a input from the user using Scanner class and then use 'toUpperCase()' method to convert the string to Uppercase. 
You can use 'toLowerCase()' to convert the String to lowercase


Code :

import java.util.Scanner;

public class LowToUp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter String in Lowercase :-");
String LowStr = sc.nextLine();

String UpStr = LowStr.toUpperCase();
System.out.println("\n"+UpStr);
}
}


Output :

Enter String in Lowercase :-
welcome to school

WELCOME TO SCHOOL


Related links

Post a Comment

0 Comments