Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E05gameInfo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String team = scanner.nextLine();
- int n = Integer.parseInt(scanner.nextLine());
- double sum = 0;
- int gamesWithAdditionalTime = 0;
- int gamesWithPenalties = 0;
- double averageMinutesPerGame = 0;
- for (int i = 1; i <= n; i++) {
- int matchLength = Integer.parseInt(scanner.nextLine());
- if (matchLength > 90 && matchLength <= 120){
- gamesWithAdditionalTime++;
- }
- else if (matchLength > 120){
- gamesWithPenalties++;
- }
- sum += matchLength;
- averageMinutesPerGame = sum / n;
- }
- System.out.printf("%s has played %.0f minutes. Average minutes per game: %.2f%n", team, sum, averageMinutesPerGame);
- System.out.printf("Games with penalties: %d%n", gamesWithPenalties);
- System.out.printf("Games with additional time: %d%n", gamesWithAdditionalTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement