import java.util.Scanner;
公司主營業(yè)務(wù):成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出洛浦免費(fèi)做網(wǎng)站回饋大家。
public class Demo {
public static void main(String[] args) {
int[][] a = new int[10][3];
String str[] = { "A", "B", "C" };
Scanner scan = new Scanner(System.in);
for (int i = 0; i 2; i++) {
for (int j = 0; j 3; j++) {
System.out.print("輸入第" + (1 + i) + "位同學(xué)的" + str[j] + "的分?jǐn)?shù):");
a[i][j] = scan.nextInt();
}
}
for (int i = 0; i 2; i++) {
for (int j = 0; j 3; j++) {
System.out.println("第" + (1 + i) + "位同學(xué)的" + str[j] + "的分?jǐn)?shù)為:"+a[i][j]);
}
}
}
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class GradeList {
public static void main(String[] args) {
ArrayListInteger list = new ArrayList();
Scanner in = new Scanner(System.in);
int grade;
System.out.print("請輸入成績,以空格隔開,鍵入-1結(jié)束:");
while ((grade = in.nextInt())!=-1){
if(grade=0grade=100)
list.add(grade);
}
System.out.println("實(shí)際統(tǒng)計(jì)的人數(shù)為:"+list.size()+"\n實(shí)際統(tǒng)計(jì)的成績?yōu)椋?+list);
System.out.println("平均分:"+getAvg(list));
System.out.println("最高分:"+getMax(list));
System.out.println("最低分:"+getMin(list));
System.out.println("不及格:"+getBad(list));
}
public static double getAvg(ArrayListInteger list){
int sum = 0;
for (int i = 0; i list.size(); i++) {
sum += list.get(i);
}
return (double)sum/list.size();
}
public static int getMax(ArrayListInteger list){
Collections.sort(list);
return list.get(list.size()-1);
}
public static int getMin(ArrayListInteger list){
Collections.sort(list);
return list.get(0);
}
public static ArrayList getBad(ArrayListInteger list){
Collections.sort(list);
ArrayListInteger badGradeList = new ArrayListInteger();
for (int index=0; index list.size(); index++) {
int grade = list.get(index);
if (grade60)
badGradeList.add(grade);
}
return badGradeList;
}
}
main方法
求平均、最高、最低、不及格方法
import java.util.Scanner;
public class Test
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int[] arr=new int[5];
float ave=0;
System.out.print("請輸入5個(gè)同學(xué)的java成績:");
for(int i=0;i5;i++)
{
arr[i]=sc.nextInt();
ave+=arr[i];
}
System.out.printf("總分 = %d; 平均分 = %.1f",(int)ave,ave/5);
System.out.println();
sc.close();
}
}
主要是下標(biāo)做了,記住數(shù)組是用0開始,現(xiàn)在調(diào)通了
import java.util.Scanner;
public class Admin {
public static void main(String... args) {
Scanner reader = new Scanner(System.in);
System.out.println("輸入用戶個(gè)數(shù):");
int score = reader.nextInt();
double score1[] = new double[score];
System.out.println("輸入用戶成績:");
for (int i = 0; i score1.length; i++) {
double s = reader.nextDouble();
score1[i] = s;
}
System.out.println("輸入查找學(xué)生");
int n = reader.nextInt();
if (n == score) {
System.out.println("第" + score + "學(xué)生成績是:" + score1[score - 1]);
}
}
}