319上机练习
package one;
public class Demo01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 5;
int b = 6;
int c = a;
a = b;
b = c;
System.out.println(a);
System.out.println(b);
}
}

1、已知a,b均是整型变量,写出将a,b两个变量中的值互换的程序。
2、给定一个0~1000的整数,求各位数的和,例如345的结果是3+4+5=12
package one; public class Demo01 { public static void main(String[] args) { // TODO Auto-generated method stub int a = 456; int ge = a%10; int shi = a/10%10; int bai = a/100%10; int total = ge + shi + bai; System.out.println(total); } }

3、华氏度与摄氏度之间的转化问题
package one; public class Demo01 { public static void main(String[] args) { // TODO Auto-generated method stub int hua = 50; int she = (hua - 32)*5/9; System.out.println(she); } }

4、给定大写字母A,将其转化为小写字母
package one; public class Demo02 { public static void main(String[] args) { // TODO Auto-generated method stub char c = 'A'; char c2 = 'A' + 32; System.out.println(c2); } }

浙公网安备 33010602011771号