Created
March 21, 2015 11:50
-
-
Save ralphbenjamin/9e131a667b5518c25157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
/** | |
* Programma om nadat de nieuwe tellingen binnen zijn, deze in te kunnen voeren | |
* en daarna een overzicht te krijgen van de partijen met het aantal zetels | |
* vroeger, nu en het verschil | |
* | |
* - 3 arrays, 1 voor de partij namen, 1 voor zetels vroeger, 1 voor nu - de | |
* partij namen staan vast - de oude aantallen zetels staan vast - methode die | |
* het verschil teruggeeft voor 1 partij tussen vroeger en nu - int | |
* verschilZetels(int[] oud, int[] nieuw, int index) | |
* ---------------------------------- Stemmen | |
* | |
* Geef het nieuwe aantal zetels CDA: 3 PVDA: 6 VVD: 9 | |
* | |
* CDA was 2 zetels, nu 3 verschil 1 PVDA was 12 zetels, nu 6 verschil -6 VVD | |
* was 9 zetels, nu 9 verschil 0 | |
*/ | |
public class Stemmen { | |
public static void main(String[] args) { | |
String[] partijNamen = {"CDA", "PVDA", "VVD"}; | |
int[] zetelsOud = {2, 12, 9}; | |
int[] zetelsNieuw = new int[partijNamen.length]; | |
System.out.println("Stemmen"); | |
System.out.println("\nGeeft het nieuwe aantal zetels"); | |
Scanner invoer = new Scanner(System.in); | |
for (int i = 0; i < partijNamen.length; i++) { | |
System.out.print(partijNamen[i] + ": "); | |
zetelsNieuw[i] = invoer.nextInt(); | |
} | |
System.out.println(""); | |
for (int i = 0; i < partijNamen.length; i++) { | |
String partij = partijNamen[i]; | |
System.out.println(partij + "was " | |
+ zetelsOud[i] + " zetels, nu " | |
+ zetelsNieuw[i] + " verschil " | |
+ verschilZetels(zetelsOud, zetelsNieuw, i)); | |
} | |
} | |
private static int verschilZetels(int[] zetelsOud, | |
int[] zetelsNieuw, int index) { | |
return zetelsNieuw[index] - zetelsOud[index]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment