Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- String match1 = scanner.nextLine();
- String match2 = scanner.nextLine();
- String match3 = scanner.nextLine();
- int homeWins = 0;
- int visitorWins = 0;
- int draws = 0;
- char homeMatchScore = match1.charAt(0);
- char visitorMatchScore = match1.charAt(2);
- if (Character.getNumericValue(homeMatchScore) > Character.getNumericValue(visitorMatchScore)) {
- homeWins++;
- }
- if (Character.getNumericValue(homeMatchScore) < Character.getNumericValue(visitorMatchScore)) {
- visitorWins++;
- }
- if (Character.getNumericValue(homeMatchScore) == Character.getNumericValue(visitorMatchScore)) {
- draws++;
- }
- homeMatchScore = match2.charAt(0);
- visitorMatchScore = match2.charAt(2);
- if (Character.getNumericValue(homeMatchScore) > Character.getNumericValue(visitorMatchScore)) {
- homeWins++;
- }
- if (Character.getNumericValue(homeMatchScore) < Character.getNumericValue(visitorMatchScore)) {
- visitorWins++;
- }
- if (Character.getNumericValue(homeMatchScore) == Character.getNumericValue(visitorMatchScore)) {
- draws++;
- }
- homeMatchScore = match3.charAt(0);
- visitorMatchScore = match3.charAt(2);
- if (Character.getNumericValue(homeMatchScore) > Character.getNumericValue(visitorMatchScore)) {
- homeWins++;
- }
- if (Character.getNumericValue(homeMatchScore) < Character.getNumericValue(visitorMatchScore)) {
- visitorWins++;
- }
- if (Character.getNumericValue(homeMatchScore) == Character.getNumericValue(visitorMatchScore)) {
- draws++;
- }
- System.out.printf("Team won %d games.\n", homeWins);
- System.out.printf("Team lost %d games.\n", visitorWins);
- System.out.printf("Drawn games: %d", draws);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement