Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- System.out.println("Napisz START aby zacząć:");
- checkInput(s);
- // Sposób z whilem
- // while (!s.nextLine().equals("start")) {
- // System.out.println("Niepoprawna komenda.");
- // }
- // System.out.println("Poprawnie wpisany start!");
- // Sposób z forem
- // for(;;){
- // if(s.nextLine().equals("start")){
- // System.out.println("Poprawnie wpisany start!");
- // break;
- // }else{
- // System.out.println("Niepoprawna komenda.");
- // }
- // }
- }
- public static void checkInput(Scanner scanner){
- while (!scanner.nextLine().equals("start")) {
- System.out.println("Niepoprawna komenda.");
- }
- System.out.println("Poprawnie wpisany start!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement