פתרון תרגיל 7 עמוד 180

פתרון תרגיל 7 עמוד 180

 

int grade,max,min,serialMax,serialMin,count = 1;

      System.out.println("please insert the first grade");

      grade = reader.nextInt();

      max = grade;

      min = grade;

      serialMax = 1;

      serialMin = 1;

     

      while (grade >= 0){

            if (grade > max){

                  max = grade;

                  serialMax = count;

            }

            if (grade < min){

                  min = grade;

                  serialMin = count;

            }

            if (grade >= 95)

                  System.out.println("הצטיינות");

                  if (grade < 55)

                        System.out.println("נכשל");

                  count++;

                  System.out.println("please insert the next grade");

                  grade = reader.nextInt();

            }

            System.out.println("Best grade is : "+max+" # : "+serialMax);

            System.out.println("Wrost grade is : "+min+" # : "+serialMin);