文章目录
尚学堂JAVA 第二章作业
第二章比较简单写得很粗略
import java.util.Scanner;
import java.math.*;
/**
* 作业2
* @author liuliuhuan
*
*/
public class work2 {
public static void main(String[] agrs) {
//CD C A AB AB
//整型:byte 1 short2 int4 long8
//boolen: 1 bit
// float 4 double 8
//char 2
/* i++ 先执行其他操作再执行加一,++i相反*/
//都是或操作,第一个短路或,只要第一项为true式子就为true,忽略第二项
/* 容量小的转容量大的自动转化,int自动转byte,short
* 可以()强制转化
*/
Scanner scanner=new Scanner(System.in);
System.out.println("plese input the radius of the circle");
float r =scanner.nextFloat();
System.out.println("the radius of the circle R="+r);
System.out.println("the perimeter of the circle C="+2*r*3.14);
System.out.println("the area of the circle S="+3.14*r*r);
System.out.println(10000);
System.out.println(Math.round(10000*0.35/100));
System.out.println("please input four positive integers");
int num=scanner.nextShort();
int a=num/1000;
int b=num/100;
int c=num/10;
int d=num%10;
a=(a+5)%10;
b=(b+5)%10;
c=(c+5)%10;
d=(d+5)%10;
System.out.println("the number after coded "+'\t'+(int)(d*1000+c*100+b*10+a));
}
}