精品专区-精品自拍9-精品自拍三级乱伦-精品自拍视频-精品自拍视频曝光-精品自拍小视频

網(wǎng)站建設(shè)資訊

NEWS

網(wǎng)站建設(shè)資訊

Java成績計算代碼 java成績單代碼

JAVA代碼問題!輸入5名學(xué)生的成績,并計算總成績,平均分,最高分,最低分

public static void main(String[] args) {

創(chuàng)新互聯(lián)公司致力于互聯(lián)網(wǎng)網(wǎng)站建設(shè)與網(wǎng)站營銷,提供網(wǎng)站設(shè)計、做網(wǎng)站、網(wǎng)站開發(fā)、seo優(yōu)化、網(wǎng)站排名、互聯(lián)網(wǎng)營銷、小程序定制開發(fā)、公眾號商城、等建站開發(fā),創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)策劃專家,為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制解決方案,幫助客戶在新的全球化互聯(lián)網(wǎng)環(huán)境中保持優(yōu)勢。

double scores[] = new double[5];

double total = 0;

double avg = 0;

double max = 0;

double min = 0;

int count=0;

String inputStr=null;

System.out.println("請輸入5名學(xué)生的成績:");

Scanner input = new Scanner(System.in);

while(count5){

try{

if(count 5){

System.out.println("請輸入第"+(count+1)+"個分?jǐn)?shù):");

}

inputStr=input.nextLine();

scores[count++]=Double.valueOf(inputStr.trim());

}catch(Exception e){

if(inputStr!=null "exit".equals(inputStr.trim())){

System.out.println("您已成功結(jié)束程序");

System.exit(0);

}

System.out.println("若想結(jié)束請輸入:exit");

System.out.print("您輸入的分?jǐn)?shù)不是數(shù)值類型,");

count--;

}

}

input.close();

Arrays.sort(scores);

min=scores[0];

max=scores[scores.length-1];

for(double score :scores){

total += score;

}

avg=total/scores.length;

System.out.println("總成績是" + total);

System.out.println("最高分是" + max);

System.out.println("最低分是" + min);

System.out.println("平均分是" + avg);

}

//-------------------------------------------------------------------------

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

while(true){

Double[] scores = null;

double total = 0;

double avg = 0;

double max = 0;

double min = 0;

int count=1;

ListDouble inputScores=new ArrayListDouble();

String inputStr=null;

System.out.println("請輸入要統(tǒng)計學(xué)生的成績(理論上可以輸入無限個,前提是你有那么大的內(nèi)存):");

while(true){

try{

System.out.println("請輸入第"+count+++"個分?jǐn)?shù),或輸入ok進行計算,離開請輸入exit");

inputStr=input.nextLine();

inputScores.add((double)Double.valueOf(inputStr.trim()));

}catch(Exception e){

if(inputStr!=null "exit".equals(inputStr.trim().toLowerCase())){

System.out.println("您已成功結(jié)束程序");

input.close();

System.exit(0);

}

if(inputStr!=null "ok".equals(inputStr.trim().toLowerCase())){

break;

}

System.out.println("您輸入的分?jǐn)?shù)不是數(shù)值類型,");

System.out.println("若想結(jié)束請輸入exit ,若想計算結(jié)果請輸入ok");

count--;

}

}

if(inputScores.size()==0){

System.out.println("您沒有輸入學(xué)生成績,無數(shù)據(jù)可統(tǒng)計,程序結(jié)束。");

return ;

}

scores=inputScores.toArray(new Double[inputScores.size()]);

Arrays.sort(scores);

min=scores[0];

max=scores[scores.length-1];

for(double score :scores){

total += score;

}

avg=total/scores.length;

System.out.println("總成績是" + total);

System.out.println("最高分是" + max);

System.out.println("最低分是" + min);

System.out.println("平均分是" + avg);

}

}

急急急java成績總成績和平均分的代碼?

//

import?java.util.Scanner;

//

public?class?Test2014?{

public?static?void?main(String[]?args)?{

Scanner?sc?=?new?Scanner(System.in);

System.out.println("輸入學(xué)生人數(shù):");

int?n?=?sc.nextInt();

int?sum?=?0;

for(int?i?=?1;i?=?n;++i){

System.out.println("輸入第"+i+"個學(xué)生成績:");

sum?+=?sc.nextInt();

}

System.out.println("總成績是:"+sum+"?"+"平均成績是:"+(double)sum/n);

}

}

java計算成績的程序

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner scan = new Scanner(System.in);

System.out.print("請輸入你要計算的科目數(shù):");

int number = scan.nextInt();

float total = 0;

float[] scores = new float[number];

for (int i = 0 ; i number ; i ++) {

System.out.print("請輸入第" + (i + 1) + "門成績:");

float score = scan.nextFloat();

scores[i] = score;

total += score;

}

System.out.println("您的各科成績?nèi)缦拢?);

for (int i = 0 ; i number ; i ++) {

System.out.println((i + 1) + ":" + scores[i]);

}

System.out.println("您的總分為:" + total);

System.out.println("平均分為:" + total/number);

}

java編寫一個成績統(tǒng)計程序

import java.util.Scanner;

public class test {

static int s;

public static void main(String[] argv) {

int [] num=new int[20];

Scanner scanner=new Scanner(System.in);

Integer a;

int i;

for(i=1;i=20;i++){

System.out.println("請輸入第"+i+"一個分?jǐn)?shù)(結(jié)束請輸入520嘿嘿):");

a=scanner.nextInt();

num[i-1]=a;

if(a==520){

break;

}

}

for(int m=0;mi-1;m++)

{

s=s+num[m];

}

System.out.println("總共錄入了"+(i-1)+"個分?jǐn)?shù)");

System.out.println("總成績是"+s+"分");

System.out.println("平均分是"+s/(i-1)+"分");

for(Integer m=0;mnum.length-1;m++)

{ if(num[m]0num[m]!=520){

if(num[m]=90)

System.out.println(num[m]+"優(yōu)秀");

else if(num[m]=80)

System.out.println(num[m]+"良好");

else if(num[m]=70)

System.out.println(num[m]+"中等");

else if(num[m]=60)

System.out.println(num[m]+"及格");

else

System.out.println(num[m]+"不及格");

}else break;

}

}

}

我的代碼很簡潔,采納我唄。。。


當(dāng)前文章:Java成績計算代碼 java成績單代碼
網(wǎng)站URL:http://m.jcarcd.cn/article/hpsees.html
主站蜘蛛池模板: 成人开心网 | 区三区日韩精品 | 中文字幕亚洲激情 | 国产乱婬 | 欧亚一级毛 | 国产99热 | 91短视频 | 国产日韩欧美新地址 | 午夜影院高清无 | 人成综合网络 | 国产网站1区2区 | 无码成人午夜在线观看 | AⅤ三区| 麻花影院| 成人国产在线视频 | 欧洲国产日产综合 | 国产福利萌白酱 | 欧洲成人午| 福利导航h污下载 | 成人精品xx | 国产终合在线 | 日韩中文字幕第二页 | 日韩精品色色色色 | 日韩大乳免费视频 | 国产主播专区 | 国产专区手机在 | 成人亚洲偷自拍色 | 青青视屏| 福利破解视频导航 | 精品一区二区视频 | 精品在线一 | 成人免费一级纶理片 | 欧美日韩综合网 | 成人理论片 | 成人二区 | 国产又爽又黄免费 | 午夜一级免费视频 | 国产综合久 | 日韩精品动漫一区 | 国产aⅴ综合 | 成人国产一区不卡 |