public class Zuoye {
public static void main(String[] args) {
int a=10;
int b=8;
int c;
c=a;
a=b;
b=c;
System.out.println("a="+a+","+"b="+b);
}
1、已知a,b均是整型变量,写出将a,b两个变量中的值互换的程序。
2、给定一个0~1000的整数,求各位数的和,
public class Zuoye1 { public static void main(String[] args) { int a=596; int qian=a/1000; int bai=a/100; int shi=a%100/10; int ge=a%10; int sum; sum=qian+bai+shi+ge; System.out.println("sum="+sum); } }
3、华氏度50转成摄氏度是多少???
public class Zuoye2 { public static void main(String[] args) { int huashi=50; int sheshi; sheshi=(huashi-32)*5/9; System.out.println("sheshi="+sheshi); } }
4、给定一个任意的大写字母A~Z,转换为小写字母。
public class Zuoye3 { public static void main(String[] args) { char a='Z'; char b='Z'+32; System.out.println("b="+b); } }