Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPrep;
- import java.util.Scanner;
- public class P02FootballResults {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int countWon = 0;
- int countLost = 0;
- int countTie = 0;
- for (int i = 0; i < 3; i++) {
- String gameResult = scanner.nextLine();
- char firstPoints = gameResult.charAt(0);
- char secondPoints = gameResult.charAt(2);
- if (firstPoints > secondPoints) {
- countWon++;
- } else if (firstPoints < secondPoints) {
- countLost++;
- } else {
- countTie++;
- }
- }
- System.out.printf("Team won %d games.%n", countWon);
- System.out.printf("Team lost %d games.%n", countLost);
- System.out.printf("Drawn games: %d%n", countTie);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement