Advertisement
Kwintendr

Untitled

Jan 17th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.16 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class Kruidvat {
  4.  
  5.     /**
  6.      * @param args
  7.      */
  8.     public static void main(String[] args) throws IOException{
  9.  
  10.        
  11.         Kruidvat.kruidvat();
  12.  
  13.     }
  14.  
  15.     static public void kruidvat() throws IOException {
  16.         InputStreamReader isr = new InputStreamReader(System.in);
  17.         BufferedReader in = new BufferedReader(isr);
  18.  
  19.         System.out.println("Hoe lang moet de rij worden?");
  20.         int N = Integer.parseInt(in.readLine());
  21.  
  22.         String[] rij = new String[N];
  23.  
  24.         for (int i = 0; i < N; i++) {
  25.             System.out.println("Geef een waarde in: ");
  26.             rij[i] = in.readLine();
  27.         }
  28.  
  29.         System.out.println("Geef de begincel: ");
  30.         int a = Integer.parseInt(in.readLine());
  31.         int teller = 0;
  32.         while (((rij[a].equals("BOM")) != true)
  33.                 && ((rij[a].equals("EMMER")) != true)&&((rij[a].equals("FLOP")) != true)) {
  34.             a = Integer.parseInt(rij[a]);
  35.             teller = teller + 1;
  36.             System.out.print(a+" -");
  37.             if (teller>N){
  38.                 rij[a] = "FLOP";
  39.             }
  40.            
  41.         }
  42.         if (rij[a].equals("BOM"))
  43.             System.out.print(" De BOM is ontploft!");
  44.         else if (rij[a].equals("FLOP")){
  45.             System.out.println(" oneindige lus!");
  46.         }
  47.         else
  48.             System.out.println(" De lont is gedooft!");
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement