Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Kruidvat {
- /**
- * @param args
- */
- public static void main(String[] args) throws IOException{
- Kruidvat.kruidvat();
- }
- static public void kruidvat() throws IOException {
- InputStreamReader isr = new InputStreamReader(System.in);
- BufferedReader in = new BufferedReader(isr);
- System.out.println("Hoe lang moet de rij worden?");
- int N = Integer.parseInt(in.readLine());
- String[] rij = new String[N];
- for (int i = 0; i < N; i++) {
- System.out.println("Geef een waarde in: ");
- rij[i] = in.readLine();
- }
- System.out.println("Geef de begincel: ");
- int a = Integer.parseInt(in.readLine());
- int teller = 0;
- while (((rij[a].equals("BOM")) != true)
- && ((rij[a].equals("EMMER")) != true)&&((rij[a].equals("FLOP")) != true)) {
- a = Integer.parseInt(rij[a]);
- teller = teller + 1;
- System.out.print(a+" -");
- if (teller>N){
- rij[a] = "FLOP";
- }
- }
- if (rij[a].equals("BOM"))
- System.out.print(" De BOM is ontploft!");
- else if (rij[a].equals("FLOP")){
- System.out.println(" oneindige lus!");
- }
- else
- System.out.println(" De lont is gedooft!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement