1.两数互换
package aa; public class text { public static void main(String[] args) { int a=1,b=2,c; c=a; a=b; b=c; System.out.println("交换后的a:"+a+",b:"+b); }
2.每位数字之和
package aa; public class text { public static void main(String[] args) { int a,b,c,d,sum; int i=6789; a=i/1000; b=i/100%10; c=i/10%10; d=i%10; sum=a+b+c+d; System.out.println("每位数字之和为:"+sum); } }
3.华氏度转摄氏度
package aa; public class text { public static void main(String[] args) { float a=50,b; b=(a-32)*5/9; System.out.println("摄氏度是:"+b); } }
4.大写字母转换小写字母
package aa; public class text { public static void main(String[] args) { char b='A'; System.out.println((char)(b+32)); } }