Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FootballResults {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String firstMatch = scanner.nextLine();
- String secondMatch = scanner.nextLine();
- String thirdMatch = scanner.nextLine();
- int won = 0;
- int lost = 0;
- int equal = 0;
- // ASCII comparison
- if (firstMatch.charAt(0) > firstMatch.charAt(2)) won++;
- else if (firstMatch.charAt(0) < firstMatch.charAt(2)) lost++;
- else equal++;
- // ASCII comparison
- if (secondMatch.charAt(0) > secondMatch.charAt(2)) won++;
- else if (secondMatch.charAt(0) < secondMatch.charAt(2)) lost++;
- else equal++;
- // ASCII comparison
- if (thirdMatch.charAt(0) > thirdMatch.charAt(2)) won++;
- else if (thirdMatch.charAt(0) < thirdMatch.charAt(2)) lost++;
- else equal++;
- System.out.printf("Team won %d games.%n", won);
- System.out.printf("Team lost %d games.%n", lost);
- System.out.printf("Drawn games: %d", equal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment