Enter n students, and input the results to determine whether the side branches

       H leadership director of the school decided to analyze all year N students test scores to find out the side branches of the students, test scores included scores language, mathematics, English three courses, the definition of the known side branches are: a door score greater than or equal to 90 courses, and two additional fraction less than 70.

Please find a number of side branches of the total students.

Input of the first row contains an integer N.

The following N lines contains three integers, Ai, Bi, Ci, followed by scores language, mathematics, English.

1<=N<=10000

0 <= Ai, Bi, Ci <= 100

Export

An integer that represents the answer

 

First, students should first write the class:

public  class StudentDemo {
     Private  int lanGrade; // language scores 
    Private  int mathGrade; // math 
    Private  int engGrade; // English results 
    public StudentDemo ( int lanGrade, int mathGrade, int engGrade) {
         the this .lanGrade = lanGrade;
         the this .engGrade = engGrade;
         the this .mathGrade = mathGrade; 
    } 

    public  int getLanGrade () {
         returnlanGrade; 
    } 

    Public  void setLanGrade ( int lanGrade) {
         this .lanGrade = lanGrade; 
    } 

    Public  int getMathGrade () {
         return mathGrade; 
    } 

    Public  void setMathGrade ( int mathGrade) {
         this .mathGrade = mathGrade; 
    } 

    Public  int getEngGrade () {
         return engGrade; 
    } 

    Public  void setEngGrade ( int engGrade) {
         this .engGrade =engGrade; 
    } 

    @Override 
    public String toString () {
         return "StudentDemo {" + 
                "lanGrade =" + lanGrade + 
                ", mathGrade =" + mathGrade + 
                ", engGrade =" + engGrade + 
                '}' ; 
    } 
}

Create a performance class :( judgment)

import java.util.Scanner;

public class GradeTest {
    private StudentDemo[] studentDemos;
    private int studentNum;
    private Scanner sc;
    public GradeTest(){
        this.sc = new Scanner(System.in);
        this.studentNum = 0;
        this.studentDemos = new StudentDemo[1000];
        this.studentDemos[this.studentNum++] = new StudentDemo(0,0,0);
    }


    public static voidmain (String [] args) { 
        GradeTest Gd = new new GradeTest (); 
        gd.setGrade (); 
        int NUM = gd.search (); 
        System.out.println ( "Number of partial subjects:" + NUM); 

    } 

    Private  void setGrade () { 
            System.out.println ( "Please enter the number of students:" );
             int NUM = sc.nextInt (); 
            System.out.println ( "Please enter student scores (score greater than or equal to 0 less than or equal to 100): " );
                int I =. 1 ;
                the while (I <= NUM) {
                    int lanGrade = sc.nextInt();
                   int mathGrade = sc.nextInt();
                   int engGrade = sc.nextInt();
                   if (i == studentNum) {
                       studentDemos[this.studentNum++] = new StudentDemo(lanGrade, mathGrade, engGrade);
                   }
                   i++;
               }

    }

    public int search() {
        int count = 0;
            for (int i = 0; i < this.studentNum; i++) {
                if ((studentDemos[i].getEngGrade() >= 90 && studentDemos[i].getLanGrade() <= 70 && studentDemos[i].getMathGrade() <= 70) ||
                        (studentDemos[i].getLanGrade() >= 90 && studentDemos[i].getEngGrade() <= 70 && studentDemos[i].getMathGrade() <= 70) ||
                        (studentDemos[i].getMathGrade() >= 90 && studentDemos[i].getLanGrade() <= 70 && studentDemos[i].getEngGrade() <= 70)) {
                    count++;
                }
            }
            return count;
        }
}

operation result:

 

Guess you like

Origin www.cnblogs.com/128-cdy/p/11921624.html