Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner s = new Scanner(System.in);
  8.  
  9.         System.out.println("Napisz START aby zacząć:");
  10.  
  11.         checkInput(s);
  12.  
  13.         // Sposób z whilem
  14. //        while (!s.nextLine().equals("start")) {
  15. //            System.out.println("Niepoprawna komenda.");
  16. //        }
  17. //        System.out.println("Poprawnie wpisany start!");
  18.  
  19.         // Sposób z forem
  20. //        for(;;){
  21. //            if(s.nextLine().equals("start")){
  22. //                System.out.println("Poprawnie wpisany start!");
  23. //                break;
  24. //            }else{
  25. //                System.out.println("Niepoprawna komenda.");
  26. //            }
  27. //        }
  28.     }
  29.  
  30.     public static void checkInput(Scanner scanner){
  31.         while (!scanner.nextLine().equals("start")) {
  32.             System.out.println("Niepoprawna komenda.");
  33.         }
  34.         System.out.println("Poprawnie wpisany start!");
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement