2020.3.19第一次上机作业
1、已知a,b均是整型变量,写出将a,b两个变量中的值互换的程序
package com.itheima01; public class HelloWorld { public static void main(String[] args) { int a=233; int b=322; int temp = a; a = b; b=temp; System.out.println(a+" "+b); } }
2、给定一个0~1000的整数,求各位数的和
package com.itheima01; public class HelloWorld { public static void main(String[] args) { int a=12; int x=12%10; int y=12/10; int sum=x+y; System.out.println("sum="+sum); } }
3、华氏度50转成摄氏度是多少
package com.itheima01; public class HelloWorld { public static void main(String[] args) { int a=50; int b=(a-32)*5/9; System.out.println("华氏度="+b); } }
4、给定一个任意的大写字母A~Z,转换为小写字母
package com.itheima01; public class HelloWorld { public static void main(String[] args) { char a = 'Z'; System.out.println((char)(a + 32)); } }