Write a java program to solve the following problem: You have N students in a class. You want a java program that
- برمجة جافا
- 2022-04-19
- softwareEngineer
الأجوبة
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("enter the number of students:");
int numberofStudents=input.nextInt();
int []grades=new int[numberofStudents];
int numOfPassStudents=0,numOfFailStudents=0,numOfExcelentStudents=0,numOfVeryGoodStudents=0,numOfGoodStudents=0,numOfAcceptanceStudents=0;
int highestGrade=-1,lowestGrade=101;
for(int i=0;i<grades.length;i++)
{
do{
System.out.println("enter grade of student "+(i+1));
grades[i]=input.nextInt();
if(grades[i]>100 || grades[i]<0)
System.out.println("invlid grade, it should be between 0 to 100");
}
while(grades[i]>100 || grades[i]<0);
if(grades[i]>=60)
{
numOfPassStudents++;
if(grades[i]>=90)
numOfExcelentStudents++;
else if(grades[i]>=80)
numOfVeryGoodStudents++;
else if(grades[i]>=70)
numOfGoodStudents++;
else numOfAcceptanceStudents++;
}
else
numOfFailStudents++;
if(grades[i]>highestGrade)
highestGrade=grades[i];
if(grades[i]<lowestGrade)
lowestGrade=grades[i];
}
System.out.println("number of passed students: "+numOfPassStudents);
System.out.println("number of failed students: "+numOfFailStudents);
System.out.println("number of excelent students: "+numOfExcelentStudents);
System.out.println("number of very good students: "+numOfVeryGoodStudents);
System.out.println("number of good students: "+numOfGoodStudents);
System.out.println("number of acceptance students: "+numOfAcceptanceStudents);
System.out.println("highest grade: "+highestGrade);
System.out.println("lowest grade: "+lowestGrade);
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال