Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. public static void main(String[] args) {
  2. String Question = null, Answer = null, Panswer = null, Continue = null, Type;
  3. int Looptimes, Nanswer = 0, PNanswer = 0, i = 0;
  4. boolean Flag = false;
  5. Scanner Input = new Scanner(System.in);
  6. System.out.println("How many times do you want to study this question?");
  7. Looptimes = Input.nextInt();
  8. System.out.println("What is the Question you need to study?");
  9. int c = 1 + 1;
  10. Question = Input.nextLine();
  11. System.out.println("What is the Answer to the Question?");
  12. Answer = Input.nextLine();
  13. System.out.flush();
  14. do {
  15. System.out.println(Question);
  16. System.out.println("What's the answer?");
  17. Panswer = Input.nextLine();
  18. if(Panswer.contentEquals(Answer)) {
  19. System.out.println("You're correct!! The answer is " + Answer);
  20. Flag = true;
  21. }else if(!Panswer.contentEquals(Answer)) {
  22. System.out.println("You're incorrect, the answer is " + Answer);
  23. Flag = false;
  24. }
  25. i++;
  26. do{
  27. if(i == Looptimes) {
  28. System.out.println("Do you want to continue?");
  29. Continue = Input.nextLine();
  30. if(Continue.contentEquals("Yes") || Continue.contentEquals("yes") || Continue.contentEquals("Yea") || Continue.contentEquals("Yeah") || Continue.contentEquals("Y") || Continue.contentEquals("y")) {
  31. Flag = false;
  32. }
  33. else if(Continue.contentEquals("No") || Continue.contentEquals("no") || Continue .contentEquals("N") || Continue.contentEquals("n") || Continue .contentEquals("Nope") || Continue.contentEquals("nope")) {
  34. System.out.println("Stopping Program");
  35. Flag = true;
  36. }else{
  37. System.out.println("Try Again!");
  38. }
  39. }
  40. } while(!(Continue.contentEquals("Yes") || Continue.contentEquals("yes") || Continue.contentEquals("Yea") || Continue.contentEquals("Yeah") || Continue.contentEquals("Y") || Continue.contentEquals("y") || Continue.contentEquals("No") || Continue.contentEquals("no") || Continue .contentEquals("N") || Continue.contentEquals("n") || Continue .contentEquals("Nope") || Continue.contentEquals("nope")))
  41. }while(Flag = false || i != Looptimes)
  42. Input.close();
  43. }
  44. }
  45.  
  46. How many times do you want to study this question?
  47. 5
  48. What is the Question you need to study?
  49. What is the Answer to the Question?
  50. w
  51.  
  52. What's the answer?
  53. w
  54. You're correct!! The answer is w
  55. Exception in thread "main" java.lang.NullPointerException
  56. at StudyIdea.main(StudyIdea.java:42)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement