# 3.5第二次上机作业

1.定义圆的半径,求圆的面积

package work;

public class Pra1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int r=2;
System.out.println(3.14*r*r);
}

}

2.华氏度摄氏度转换

package work;

public class Copy_2_of_Pra1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double d=41;
System.out.println((d-32)*5/9);
double s=5;
System.out.println(s*9/5+32);

}

}

3.a  b 变量值的互换

package work;

public class Copy_3_of_Pra1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 100,b = 102;
int temp = a;
a = b;
b = temp;
System.out.println(a+" "+b);
}

}

4.任意五位数,保留到百位

package work;

public class CopyOfPra1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a =12345;
int b;
b=a/100*100;

System.out.println(b);
}

}

5.0~1000的整数,求各位数的和

package work;

public class Copy_4_of_Pra1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 234;
int b, c, d, sum;

b = a / 100 ;
c = a  / 10 % 10;
d = a % 10;
sum = b +c +d ;
System.out.println("结果为" + sum);
}

}

6.字母大小写转换

package work;

public class Copy_5_of_Pra1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
for(char a='A';a<='Z';a++)
System.out.println((int) a);
for(char b='a';b<='z';b++)
System.out.println((int) b);

}

}

posted @ 2021-03-12 10:07  Miraitowa~~~  阅读(39)  评论(0编辑  收藏  举报