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);
- String firstGame = scanner.nextLine();
- String secondGame = scanner.nextLine();
- String thirdGame = scanner.nextLine();
- int winCounter = 0;
- int lostCounter = 0;
- int drawCounter = 0;
- char firstGameFirstResult = firstGame.charAt(0);
- char firstGameSecondResult = firstGame.charAt(2);
- if (firstGameFirstResult > firstGameSecondResult) {
- winCounter++;
- } else if (firstGameFirstResult < firstGameSecondResult) {
- lostCounter++;
- } else {
- drawCounter++;
- }
- char secondGameFirstResult = secondGame.charAt(0);
- char secondGameSecondResult = secondGame.charAt(2);
- if (secondGameFirstResult > secondGameSecondResult) {
- winCounter++;
- } else if (secondGameFirstResult < secondGameSecondResult) {
- lostCounter++;
- } else {
- drawCounter++;
- }
- char thirdGameFirstResult = thirdGame.charAt(0);
- char thirdGameSecondResult = thirdGame.charAt(2);
- if (thirdGameFirstResult > thirdGameSecondResult) {
- winCounter++;
- } else if (thirdGameFirstResult < thirdGameSecondResult) {
- lostCounter++;
- } else {
- drawCounter++;
- }
- System.out.printf("Team won %d games.%n", winCounter);
- System.out.printf("Team lost %d games.%n", lostCounter);
- System.out.printf("Drawn games: %d%n", drawCounter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement