Advertisement
veronikaaa86

02. Football Results

Jun 19th, 2021
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P02FootballResults {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String firstGame = scanner.nextLine();
  10. String secondGame = scanner.nextLine();
  11. String thirdGame = scanner.nextLine();
  12.  
  13. int winCounter = 0;
  14. int lostCounter = 0;
  15. int drawCounter = 0;
  16.  
  17. char firstGameFirstResult = firstGame.charAt(0);
  18. char firstGameSecondResult = firstGame.charAt(2);
  19. if (firstGameFirstResult > firstGameSecondResult) {
  20. winCounter++;
  21. } else if (firstGameFirstResult < firstGameSecondResult) {
  22. lostCounter++;
  23. } else {
  24. drawCounter++;
  25. }
  26.  
  27. char secondGameFirstResult = secondGame.charAt(0);
  28. char secondGameSecondResult = secondGame.charAt(2);
  29. if (secondGameFirstResult > secondGameSecondResult) {
  30. winCounter++;
  31. } else if (secondGameFirstResult < secondGameSecondResult) {
  32. lostCounter++;
  33. } else {
  34. drawCounter++;
  35. }
  36.  
  37. char thirdGameFirstResult = thirdGame.charAt(0);
  38. char thirdGameSecondResult = thirdGame.charAt(2);
  39. if (thirdGameFirstResult > thirdGameSecondResult) {
  40. winCounter++;
  41. } else if (thirdGameFirstResult < thirdGameSecondResult) {
  42. lostCounter++;
  43. } else {
  44. drawCounter++;
  45. }
  46.  
  47. System.out.printf("Team won %d games.%n", winCounter);
  48. System.out.printf("Team lost %d games.%n", lostCounter);
  49. System.out.printf("Drawn games: %d%n", drawCounter);
  50. }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement