-
Notifications
You must be signed in to change notification settings - Fork 0
/
ques6.java
32 lines (23 loc) · 852 Bytes
/
ques6.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// // You are given uppercase string (S) and you have to return a string that is the lower case form of S.
// Uppercase strings are those which have all letters in uppercase (Example: MACHINE)
// Lowercase strings are those which have all letters in lowercase (Example: machine)
import java.util.*;
public class ques6 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
System.out.println(uppr(str));
}
public static String uppr(String str){
String result = "";
for(int i = 0 ; i <str.length() ; i++){
if(str.charAt(i) >= 'A' && str.charAt(i) <= 'Z'){
result += (char)(str.charAt(i) - 'A' + 'a');
}
else{
result += str.charAt(i);
}
}
return result ;
}
}