Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab1_16;
- import java.util.Scanner;
- class Stud {
- public String fio; //ФИО
- public int kurs; //курс
- public int gr; //группа
- public byte math; //оценка по математике
- public byte phis; //оценка по физике
- public byte prog; //оценка по программированию
- }
- public class Lab1_16 {
- static int inputData(Stud[] ar) {
- Scanner sc = new Scanner(System.in);
- int count = 0;
- for (int i = 0; i < ar.length; i++) {
- ar[i] = new Stud();
- System.out.println("Введите ФИО ");
- ar[i].fio = sc.nextLine();
- if (ar[i].fio.isEmpty()) {
- break;
- }
- System.out.println("Курс");
- ar[i].kurs = sc.nextInt();
- System.out.println("Группа");
- ar[i].gr = sc.nextInt();
- System.out.println("Оценка по математике");
- ar[i].math = sc.nextByte();
- System.out.println("Оценка по физике");
- ar[i].phis = sc.nextByte();
- System.out.println("Оценка по программированию");
- ar[i].prog = sc.nextByte();
- sc.nextLine();
- ++count;
- }
- return count;
- }
- static void getBotcher(Stud[] ar, int count) {
- for(int i=0;i<count;++i){
- if (ar[i].math == 2 || ar[i].phis == 2 || ar[i].prog == 2) {
- System.out.println(ar[i].fio);
- }
- }
- }
- static int getHighAchievers(Stud[] ar, int count){
- int kol=0;
- for(int i=0; i<count;++i){
- if(ar[i].math>3 && ar[i].phis>3 && ar[i].prog>3){
- ++kol;
- }
- }
- return kol;
- }
- static void getBestStud(Stud[] ar, int count){
- int max=0;
- for(int i=0;i<count;++i){
- if(max<ar[i].math + ar[i].phis + ar[i].prog){
- max=ar[i].math + ar[i].phis + ar[i].prog;
- abc=ar[i].fio;
- }
- }
- System.out.println(abc);
- }
- public static void main(String[] args) {
- Stud[] ar = new Stud[100];
- int k = inputData(ar);
- System.out.println(k);
- getBotcher(ar,k);
- int p=getHighAchievers(ar,k);
- System.out.println(p);
- getBestStud(ar,k);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement