2020-10-01

java string case change

Input a string, change uppercase characters to lowercase, lowercase to uppercase, and then output
Input format
  acbAB
Output format
  ACBab
sample input
An input example that meets the requirements of the title.
Example:
acbAB
sample output
The output corresponding to the sample input above.
Example:
ACBab
Data Scale and Conventions
  Enter the range of each number in the data.
  Example: 0<n,m<100, 0<=each number in the matrix<=1000.

public class Demo6 {
    
    
	public static void main(String[] args) {
    
    
		int n,m;
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		for (int i=0;i<s.length();i++) {
    
    
			n=s.charAt(i);
			if(n>=97){
    
    
				m=n-32;
			}else{
    
    
				m=n+32;
			}
			System.out.print((char)m);
		}
	}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325057901&siteId=291194637