Advertisement
alawwirbilal

Seminar 1 Task 2

Oct 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class myApp {
  4. public static void main(String[] args){
  5. Scanner input = new Scanner(System.in);
  6. String q1,q2,q3,q4;
  7. boolean answer = true;
  8. while (answer) {
  9.  
  10.  
  11. System.out.println("please answer this questions! ");
  12. System.out.print("1) What is your name? ");
  13. q1 = input.nextLine();
  14. input.nextLine();
  15. System.out.print("2) How old are you? ");
  16. q2 = input.nextLine();
  17. System.out.print("3) what is your favorite color? ");
  18. q3 = input.nextLine();
  19. System.out.print("4) How many years have you been here in sweden? ");
  20. q4 = input.nextLine();
  21.  
  22.  
  23. System.out.printf("your answers are: %n 1) %s %n 2) %s %n 3) %s %n 4) %s %n ", q1, q2, q3, q4);
  24. System.out.print("are your answers right?(y/n)");
  25. String Answer = input.next();
  26. if (Answer.equals("y")){
  27. System.out.println("thank you for answering! ");
  28. answer = false;
  29. }
  30. }
  31.  
  32.  
  33.  
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement