Advertisement
Mohinder

Oefententamen

Oct 24th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package nl.hva;
  7. import java.util.Scanner;
  8. import java.util.Arrays;
  9.  
  10. /**
  11. *
  12. * @author borisdebie
  13. */
  14. public class Oefententamen {
  15.  
  16. /* Controleren of team 1 gewonnen heeft. */
  17. public static boolean getWin(int a, int b) {
  18. boolean startValue = false;
  19. if (a > b) {
  20. startValue = true;
  21. return startValue;
  22. } else {
  23. startValue = false;
  24. return startValue;
  25. }
  26. }
  27.  
  28. /* Het weergeven van de winnaar. */
  29. public static void printWinnaar(String teamOne, String teamTwo, int puntenOne,
  30. int puntenTwo, int count) {
  31. System.out.println("wedstrijd " + count + ": " + teamOne + " - "
  32. + teamTwo + " " + puntenOne + " - " + puntenTwo);
  33. }
  34.  
  35. public static void main(String[] args) {
  36. Scanner input = new Scanner(System.in);
  37. String teamOne, teamTwo;
  38. int[] puntenOne = new int[7];
  39. int[] puntenTwo = new int[7];
  40. int winsOne = 0;
  41. int winsTwo = 0;
  42.  
  43. System.out.println("Dit programma is gemaakt door Boris de Bie"
  44. + ", IB104, 50072938");
  45. System.out.print("Naam van team 1: ");
  46. teamOne = input.nextLine();
  47. System.out.print("Naam van team 2: ");
  48. teamTwo = input.nextLine();
  49.  
  50. for(int i = 0; i < puntenOne.length; i++) {
  51. System.out.println("\nUitslag wedstrijd " + (i + 1));
  52. System.out.print("Aantal punten " + teamOne + ":");
  53. puntenOne[i] = input.nextInt();
  54. System.out.print("Aantal punten " + teamTwo + ": ");
  55. puntenTwo[i] = input.nextInt();
  56. if(getWin(puntenOne[i], puntenTwo[i]) == true) {
  57. winsOne++;
  58. } else {
  59. winsTwo++;
  60. }
  61. if(winsOne == 4 || winsTwo == 4) {
  62. break;
  63. }
  64. }
  65.  
  66. System.out.println("\nAantal gespeelde wedstrijden: " + (winsOne + winsTwo));
  67. if(winsOne > winsTwo) {
  68. System.out.println(teamOne + " heeft gewonnen met " + winsOne + " - " + winsTwo);
  69. } else {
  70. System.out.println(teamTwo + " heeft gewonnen met " + winsTwo + " - " + winsOne);
  71. }
  72.  
  73. for(int i = 0; i < (winsOne + winsTwo); i++) {
  74. printWinnaar(teamOne, teamTwo, puntenOne[i], puntenTwo[i], (i + 1));
  75. }
  76.  
  77. }
  78.  
  79.  
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement