package njtcstudent.com; import java.util.Scanner; public class Seond { public static void main(String[] args) { findMax();//给定一组字符,编程输出里面数值最大者 reverseOrder();//对数组中每一个元素赋值后,按逆序输出 maxToMinOrder();//对给定一整型数组,按从大到小顺序输出 printInt();//给定一个字符串,编程输出里面所包含的数字 whatNumber();//1000以内的水仙花数 } public static void whatNumber() { int ge,shi,bai; int i; for(i=100;i<1000;i++){ bai=i/100; shi= i%100/10; ge=i%100%10; if((Math.pow(bai, 3)+Math.pow(shi, 3)+Math.pow(ge, 3))==i) System.out.println(i); } } public static void printInt() { String strThree = "sdf92r2t4h423rj23r2fj23"; int len = strThree.length(); for(int i=0 ;i<len;i++){ if(strThree.charAt(i)>='0'&&strThree.charAt(i)<='9') System.out.println(strThree.charAt(i)); } } public static void maxToMinOrder() { int[] intarry = {1,5,7,64,87,125,75,48,96,78,56,128,47,25}; int i,j,temp; for(i=0;i<intarry.length;i++) for(j=i+1;j<intarry.length;j++) { if(intarry[j]>intarry[i]){ temp=intarry[i]; intarry[i]=intarry[j]; intarry[j]=temp; } } for(i=0;i<intarry.length;i++){ System.out.print(intarry[i]+" "); System.out.println(); } } public static void reverseOrder() { String[] strTwo = {"neijiang","shifan","jike","xueyuan","sofeware","third","class"}; for(int i=strTwo.length-1;i>=0;i--){ System.out.println(strTwo[i]); } } public static void findMax() { Scanner inputOne = new Scanner(System.in); System.out.print("请输入一个字符:"); String strlone; strlone = inputOne.next(); int max=strlone.charAt(0); int i; for(i=1;i<strlone.length();i++){ if(max<strlone.charAt(i)) max=strlone.charAt(i); } System.out.println("The max value is:"+(char)max); } }
2、3班的这个。
4班的第二个实验报告,只做了第四个,我写的如下:
package com.njtcstudent.javademo; import java.util.Scanner; public class wuliantwo { public static void main(String[] args) { first();//选择分支结构那个 second();//循环结构那个 } private static void second() { int i,s=1; for(i=10;i>=1;i--) { s=s*i; System.out.println(i); } System.out.println("10!的值为:"+s); } private static void first(){ Scanner myIn = new Scanner(System.in); System.out.println("请输入一个成绩(百分制):"); int gread; gread = myIn.nextInt(); if(gread>=0 && gread<=100){ gread=gread%10; switch(gread){ case 10:case 9: System.out.println("A"); break; case 8: System.out.println("B"); break; case 7: System.out.println("C"); break; default: System.out.println("E"); } } else System.out.println("您输入的成绩有误!"); } }