Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. package lab1_16;
  2.  
  3. import java.util.Scanner;
  4.  
  5. class Stud {
  6.  
  7.     public String fio;  //ФИО
  8.     public int kurs; //курс
  9.     public int gr; //группа
  10.     public byte math; //оценка по математике
  11.     public byte phis; //оценка по физике
  12.     public byte prog; //оценка по программированию
  13. }
  14.  
  15. public class Lab1_16 {
  16.  
  17.     static int inputData(Stud[] ar) {
  18.         Scanner sc = new Scanner(System.in);
  19.         int count = 0;
  20.         for (int i = 0; i < ar.length; i++) {
  21.             ar[i] = new Stud();
  22.             System.out.println("Введите ФИО ");
  23.             ar[i].fio = sc.nextLine();
  24.             if (ar[i].fio.isEmpty()) {
  25.                 break;
  26.             }
  27.             System.out.println("Курс");
  28.             ar[i].kurs = sc.nextInt();
  29.             System.out.println("Группа");
  30.             ar[i].gr = sc.nextInt();
  31.             System.out.println("Оценка по математике");
  32.             ar[i].math = sc.nextByte();
  33.             System.out.println("Оценка по физике");
  34.             ar[i].phis = sc.nextByte();
  35.             System.out.println("Оценка по программированию");
  36.             ar[i].prog = sc.nextByte();
  37.             sc.nextLine();
  38.             ++count;
  39.  
  40.         }
  41.         return count;
  42.  
  43.     }
  44.  
  45.     static void getBotcher(Stud[] ar, int count) {
  46.         for(int i=0;i<count;++i){
  47.             if (ar[i].math == 2 || ar[i].phis == 2 || ar[i].prog == 2) {
  48.                 System.out.println(ar[i].fio);
  49.             }    
  50.     }
  51.     }
  52.     static int getHighAchievers(Stud[] ar, int count){
  53.         int kol=0;
  54.         for(int i=0; i<count;++i){
  55.             if(ar[i].math>3 && ar[i].phis>3 && ar[i].prog>3){
  56.                 ++kol;
  57.             }
  58.         }
  59.         return kol;
  60.     }
  61.     static void getBestStud(Stud[] ar, int count){
  62.         int max=0;
  63.        
  64.         for(int i=0;i<count;++i){
  65.             if(max<ar[i].math + ar[i].phis + ar[i].prog){
  66.                 max=ar[i].math + ar[i].phis + ar[i].prog;
  67.                  abc=ar[i].fio;
  68.             }
  69.            
  70.         }
  71.         System.out.println(abc);
  72.     }
  73.     public static void main(String[] args) {
  74.         Stud[] ar = new Stud[100];
  75.         int k = inputData(ar);
  76.         System.out.println(k);
  77.         getBotcher(ar,k);
  78.         int p=getHighAchievers(ar,k);
  79.         System.out.println(p);
  80.         getBestStud(ar,k);
  81.     }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement