Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exam {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numberCompanies = Integer.parseInt(scanner.nextLine());
- String winner = "";
- double winScore = 0.0;
- for (int company = 1; company <= numberCompanies; company++) {
- String name = scanner.nextLine();
- String input = scanner.nextLine();
- double middlePas = 0.0;
- int counter = 0;
- while (!input.equals("Finish")) {
- counter++;
- int passengers = Integer.parseInt(input);;
- middlePas += passengers;
- input = scanner.nextLine();
- }
- middlePas = Math.floor(middlePas/counter);
- System.out.printf("%s: %.0f passengers.%n", name,middlePas);
- if(winScore < middlePas){
- winScore = middlePas;
- winner = name;
- }
- }
- System.out.printf("%s has most passengers per flight: %.0f",winner,Math.floor(winScore));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement