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