Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication1;
- import java.util.Scanner;
- class Students {
- private String name;
- private double missed, justified;
- private double totalMissed,totalJustified,totalHours;
- public Students(String name, int missed, int justified) {
- this.name = name;
- this.missed = missed;
- this.justified = justified;
- }
- public Students(){};
- public String getName() {return name;}
- public double getMissed() {return missed;}
- public double getJustified() {return justified;}
- public double getTotalMissed() {return totalMissed;}
- public double getTotalJustified() {return totalJustified;}
- public double getTotalHours() {return totalHours;}
- public double Percent(double missedHours) {
- return missedHours*100/getMissed();
- }
- public double MissedInHours() {
- return missed-justified;
- }
- public void setTotalMissed(double totalMissed) {
- this.totalMissed += totalMissed;
- }
- public void setTotalJustified(double totalJustified) {
- this.totalJustified += totalJustified;
- }
- public void setTotalHours(double totalHours) {
- this.totalHours += totalHours;
- }
- }
- public class Main {
- public static void main(String[] args) {
- String name;
- int missed, hours, lenght, count = 1;
- Scanner countStudent = new Scanner(System.in);
- System.out.print("Введите количество Студентов: ");
- lenght = countStudent.nextInt();
- Students total = new Students();
- Students[] Students = new Students[lenght];
- for (int i = 0; i < lenght; i++) {
- Scanner check = new Scanner(System.in);
- System.out.print("Введите Фамилию " + count + "-го студента: ");
- name = check.nextLine();
- System.out.print("Пропущено всего часов у " + count + " студента: ");
- missed = check.nextInt();
- System.out.print("Оправдано часов у " + count + " студента: ");
- hours = check.nextInt();
- Students[i] = new Students(name, missed, hours);
- count++;
- }
- System.out.println("╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗");
- System.out.println("║ | Пропущено, часов | Пропуск ");
- System.out.println("║ Фамилия |__________________________________________________|_________________________________| ");
- System.out.println("║ | ВСЕГО | ОПРАВДАНО | В ЧАСАХ | В ПРОЦЕНТАХ ");
- System.out.println("╠═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╣");
- for (int i = 0; i < lenght; i++) {
- System.out.format("║ %-11s | %-25s| %-21s | %-13s | %.2f %n" ,Students[i].getName() , Students[i].getMissed(),Students[i].getJustified(), Students[i].MissedInHours() ,Students[i].Percent(Students[i].MissedInHours()));
- System.out.format("╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝%n");
- total.setTotalMissed(Students[i].getMissed());
- total.setTotalJustified(Students[i].getJustified());
- total.setTotalHours(Students[i].MissedInHours());
- }
- System.out.format("║ %-11s | %-25s| %-21s | %-13s | %n" ,"ИТОГО:",total.getTotalMissed(), total.getTotalJustified(),total.getTotalHours());
- System.out.format("╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝%n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement