fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. // WhileTasks
  5.  
  6. public static void main (String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. System.out.println("Buy an elephant!");
  9. String userAnswer = scanner.nextLine();
  10. String rightAnswer = "Ok";
  11. int count = 1;
  12.  
  13. while(true) {
  14. if(userAnswer.equals(rightAnswer)) {
  15. if (count > 1) {
  16. System.out.println("Vot tak bi srazu!");
  17. }
  18. System.out.println("Take care, its yours!");
  19. break;
  20. } else {
  21. System.out.println("Everyone says: \"" + userAnswer + "\", but you have to buy an elephant!");
  22. userAnswer = scanner.nextLine();
  23. }
  24. count++;
  25. }
  26.  
  27. scanner.close();
  28.  
  29. }
  30. }
Success #stdin #stdout 0.22s 60824KB
stdin
no
Ok
stdout
Buy an elephant!
Everyone says: "no", but you have to buy an elephant!
Vot tak bi srazu!
Take care, its yours!