public class Deam01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入一个整数");
if (scanner.hasNextInt()){ //hasNextInt()判断输入的数字是不是一个整数类型
int anInt = scanner.nextInt();
System.out.println("你输入的整数是:");
}else {
System.out.println("你个傻得");
}
}
}
public class Deam02 {
public static void main(String[] args) {
//求输入的数字的综合和平均值
Scanner scanner = new Scanner(System.in);
System.out.println("亲输入数字");
//定义一个计数器和一个累加器
int a = 0;
double sum = 0;
while (scanner.hasNextDouble()){
double v = scanner.nextDouble();
a++;
sum=sum +v;
System.out.println("你输入的是第:"+a+"个数");
}
System.out.println("输入的数的和为:"+sum);
System.out.println("输入的数的和为:"+sum/a);
}
}
public class Deam03 {
public static void main(String[] args) {
/*
* 求100以内的偶数和基数和
* */
int aaa = 0;//基数
int bbb = 0;//偶数
for (int i = 0; i < 100; i++) {
if (i%2!=0){
aaa+=i;
}else{
bbb+=i;
}
}
System.out.println(aaa);
System.out.println(bbb);
}
}
public class Deam04 {
public static void main(String[] args) {
//打印三角形
for (int i = 1; i <= 5; i++) {
for (int j = 5; j >= i; j--) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
for (int j = 1; j < i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
public class Deam01 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请输入一个整数"); if (scanner.hasNextInt()){ //hasNextInt()判断输入的数字是不是一个整数类型 int anInt = scanner..