Advertisement
apez1

Term 2: Lesson 2 - Coding Activity

Dec 11th, 2018
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package project;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5. import java.math.*;
  6.  
  7. public class newTest {
  8.  
  9.     public static void main(String[] args) {
  10.  
  11.         Scanner scanner = new Scanner(System.in);
  12.         ArrayList<String> list = new ArrayList<String>();
  13.  
  14.         int flag = 0;
  15.         String input = "";
  16.  
  17.         System.out.println("Please enter words, enter STOP to stop the loop.");
  18.         while (flag == 0) {
  19.  
  20.             input = scanner.nextLine();
  21.  
  22.             if (input.equals("STOP")) {
  23.  
  24.                 flag = 1;
  25.                 //System.out.println("BROKEN");
  26.  
  27.             }
  28.  
  29.             list.add(input);
  30.  
  31.         }
  32.  
  33.         System.out.println();
  34.        
  35.         for(String e: list) {
  36.            
  37.             if(e.contains("a")) {
  38.                
  39.                 System.out.println(e);
  40.                
  41.             }
  42.            
  43.            
  44.         }
  45.        
  46.        
  47.        
  48.        
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement