當前位置:首頁 » 考試成績 » java編寫學生成績是否合格

java編寫學生成績是否合格

發布時間: 2021-01-03 12:15:38

『壹』 JAVA利用分支語句對於學生的成績進行判斷輸出是否及格

看一下是否能幫助到你,你也可以到他們官網上免費學習這寫基礎知識。希望你早日學有所成!天天進步

『貳』 java編程,用switch語句編寫一個學生成績等級評定,使用鍵盤讀取分數(0-100之間)學生成

importjava.util.Scanner;
publicclassGetGrade{
publicstaticvoidmain(String[]args){
System.out.println("請輸入成績(1-100)");
Scannersc=newScanner(System.in);
intscore=sc.nextInt();
if(score<0||score>100){
System.out.println("對不起,你輸入有誤");
return;
}
System.out.println("你獲得了:"+getGrade(score));
}
publicstaticStringgetGrade(inti){
Stringret=null;
switch(i/10){
case10:
ret="A";
break;
case9:
ret="A";
break;
case8:
ret="B";
break;
case7:
ret="C";
break;
case6:
ret="D";
break;
default:
ret="E";
break;
}
returnret;
}
}

『叄』 java編寫程序 4. 編寫程序,從鍵盤輸入學生成績,根據成績判斷:如果成績小於60,則輸出「不及格」;若成

publicstaticvoidmain(String[]args)throwsException{
System.out.print("請輸入成績:");
Scannersc=newScanner(System.in);
Stringstr=sc.nextLine();
try{
intscore=Integer.parseInt(str);
if(score>=0&&score<60){
System.out.println("不及格");
}elseif(score>=60&&score<75){
System.out.println("及格");
}elseif(score>=75&&score<90){
System.out.println("良");
}elseif(score>=90&&score<=100){
System.out.println("優");
}else{
System.out.println("成績無效");
}
}catch(NumberFormatExceptione){
System.out.println("成績輸入錯誤");
}
}

代碼還是自己敲的好

『肆』 用Java編程輸入學生成績的等級,給出相應的成績范圍。知道

有判斷語句,首先判斷用戶輸入的信息,然後設置不同的條件下的顯示OK了

『伍』 編寫程序判斷一個學生的成績是及格還是不及格

double score =100;//獲取學生分數
string grade=「及格」;//定義一個等級,默認及格
if(score<60)//判斷分數是否小於60,自定義及格線
{
grade=「不及格」;

}

『陸』 怎樣用java編寫程序實現學生成績等級劃分,輸入考試成績,程序會相應輸出成績等級

import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner x = new Scanner(System.in);
System.out.println("請輸入成績");
int a=x.nextInt();
int n=a/10; //百分制轉換為等第
switch(n){
case 10: //表示如果n=10,也就是一百分,輸出A
case 9:
System.out.println("A");
break;
case 8:
System.out.println("B");
break;
case 7:
System.out.println("C");
break;
case 6:
System.out.println("D");
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
System.out.println("FAIL"); //低於六十分的輸出不及格 FAIL
break;
default:System.out.println(" 請輸入一個正確的成績"); //輸入的不是百分制,報錯
}
}
}

『柒』 java編程,用switch語句編寫一個學生成績等級評定

如圖:輸入大於100或者小於0得數會提示錯誤

importjava.util.Scanner;
publicclassTest{
publicstaticvoidmain(String[]args){
Scannerinput=newScanner(System.in);
System.out.println("請輸入成績:");
intscore=input.nextInt();
if(score>=0&&score<=100){
switch(score/10){
case10:case9:System.out.println("A");
break;case8:System.out.println("B");
break;case7:System.out.println("C");
break;case6:System.out.println("D");
break;
default:
case5:case4:case3:case2:case1:case0:
System.out.println("E");break;}}
else{System.out.println("數據錯誤!");}
}
}

『捌』 (java)編寫一個學生成績分析程序

//學生類
publicclassStudent{
privateStringNO;
privateStringname;
privateintmath;
privateintphysics;
privateintenglish;
privateinttotal=0;
publicStudent(StringNO,Stringname,intmath,intphysics,intenglish){
this.NO=NO;
this.name=name;
this.math=math;
this.physics=physics;
this.english=english;
total=math+physics+english;
}
publicStringgetNO(){
returnNO;
}
publicvoidsetNO(StringnO){
NO=nO;
}
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicintgetMath(){
returnmath;
}
publicvoidsetMath(intmath){
this.math=math;
}
publicintgetPhysics(){
returnphysics;
}
publicvoidsetPhysics(intphysics){
this.physics=physics;
}
publicintgetEnglish(){
returnenglish;
}
publicvoidsetEnglish(intenglish){
this.english=english;
}
publicintgetTotal(){
returntotal;
}
publicvoidsetTotal(inttotal){
this.total=total;
}
@Override
publicStringtoString(){
return"[學號="+NO+",姓名="+name+",數學成績="+math+",物理成績="+physics+",英語="
+english+",總分="+total+"]";
}


}

//排序
<Student>{

@Override
publicintcompare(Studento1,Studento2){

returno1.getTotal()<o2.getTotal()?1:o1.getTotal()==o2.getTotal()?0:-1;
}

}

publicclassTest{

publicstaticvoidmain(String[]args){
Stringfilename="res/student.txt";
System.out.println("讀取"+filename+"文件的數據");
List<Student>result=readStudnetInfoFromFile(filename);

//排序
result.sort(newCompareStudent());

System.out.println("排序輸出");
for(Studentstudent:result){
System.out.println(student);
}
System.out.println();
//不及格
System.out.println("數學不及格");
intnums=0;
for(Studentstudent:result){
if(student.getMath()<60){
System.out.println(student.getName()+"數學成績不及格");
nums++;
}
}
System.out.println("數學不及格總共有"+nums+"人");
}



//從文件中讀取數據
privatestaticList<Student>readStudnetInfoFromFile(Stringfilename){
Filefile=newFile(filename);
if(!file.exists()){
returnnull;
}
List<Student>result=newArrayList<>();
BufferedReaderbr=null;
FileReaderfr=null;
try{
fr=newFileReader(file);
br=newBufferedReader(fr);
Stringline=null;
while((line=br.readLine())!=null){
String[]infos=line.split("_");
Studentstu=newStudent(infos[0],infos[1],Integer.parseInt(infos[2]),Integer.parseInt(infos[3]),
Integer.parseInt(infos[4]));
result.add(stu);
}

}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{

try{
if(br!=null){
br.close();
}
if(fr!=null){
fr.close();
}
}catch(IOExceptione){
e.printStackTrace();
}

}

returnresult;
}


//數據文件注意文件路徑
1_張三_60_70_80
2_李四_58_58_73
3_王二_63_75_85
4_莉莉_46_75_88
5_小明_85_76_56

『玖』 編寫程序,輸入一個學生成績,給出相應等級:60~100優秀0~50不及格(java代碼實現)

import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("請輸入學生的分抄數:");
double score = input.nextDouble();
int level1,level2;
if(score>=60.0 && score<=100.0){
System.out.print("該學生成績為優秀!");
}
else if(score>=0&& score<60.0){
System.out.print("該學生成績為不及格!");
}
else{
System.out.print("您輸入的成績有誤!");

}
}
}

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919