1.已知a,b均是整型变量,写出将a,b两个变量中的值互换的程序。(知识点:变量和 运算符综合应用)
package practise; public class zuoye { public static void main(String[] args) { int a = 3; int b = 6; int c = 0; c=a; a=b;b=c; System.out.println(a); System.out.println(b); } }
2.给定一个0~1000的整数,求各位数的和,
package practise; public class zuoye { public static void main(String[] args) { int a=234; int g,s,b; int sum= 0; b=a/100; s=(a/10)%10; g=a%10; System.out.println(sum=g+s+b); } }
3.华氏度50转成摄氏度是多少???
package practise; public class zuoye { public static void main(String[] args) { int F=50,C; C=(F-32)*5/9; System.out.println(C); } }
4.给定一个任意的大写字母A~Z,转换为小写字母。
package practise; public class zuoye { public static void main(String[] args) { char a='C'; a+=32; System.out.println(a); } }