importjava.util.Scanner;//Easy is the best!publicclassDemo03{publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);System.out.println("用nextLine方法接收:");String str = scanner.nextLine();System.out.println("输出的内容为:"+ str);
scanner.close();}}
importjava.util.Scanner;//输入多个数字 并求出其总和与平均数 每输入一个数字用回车确认 通过输入非数字来结束输入并输出执行结果publicclassDemo04{publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);double sum =0;int n =0;while(scanner.hasNextDouble()){
sum += scanner.nextDouble();
n +=1;System.out.println("输入第"+ n +"个数,其总和为:"+ sum);}System.out.println(n +"个数总和为:"+ sum +" 其平均值为:"+ sum/n);
scanner.close();}}
//计算0到100之间到奇数和偶数的和publicclassDemo06{publicstaticvoidmain(String[] args){int sumOdd =0;int sumEven =0;for(int i =0; i <=100; i++){if(i%2!=0){
sumOdd += i;}else{
sumEven += i;}}System.out.println(sumOdd);System.out.println(sumEven);}}
//用for循环输出1-1000之间能被5整除的数 并且每行输出3个publicclassDemo07{publicstaticvoidmain(String[] args){for(int i =1; i <=1000; i++){if(i%5==0){System.out.print(i +"\t");}if(i%15==0){System.out.println();}}}}