-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle.java
More file actions
44 lines (38 loc) · 1.03 KB
/
toggle.java
File metadata and controls
44 lines (38 loc) · 1.03 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.Scanner;
public class toggle {
public static void main(String[] args)
{
System.out.println("Please Enter Text");
String str;
Scanner sc=new Scanner(System.in);
str=sc.nextLine();
String ans="";
/*char ch[]=str.toCharArray();*/
for(int i=0;i<str.length();i++) {
char ch=str.charAt(i);
if(ch>=97&&ch<=122)
{
ans=ans+(char)(ch-32);
}
else if(ch>=65&&ch<=90)
{
ans=ans+(char)(ch+32);
}
else {
ans=ans+ch;
}
}
System.out.println(ans);
}
}
/*if( Character.isUpperCase(ch[i]))
{
ch[i] = Character.toLowerCase(ch[i]);
}
else if(Character.isLowerCase(ch[i]))
{
ch[i]=Character.toUpperCase(ch[i]);
}
}
str=new String(ch);
System.out.println(str);*/