Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String Question = null, Answer = null, Panswer = null, Continue = null, Type;
- int Looptimes, Nanswer = 0, PNanswer = 0, i = 0;
- boolean Flag = false;
- Scanner Input = new Scanner(System.in);
- System.out.println("How many times do you want to study this question?");
- Looptimes = Input.nextInt();
- System.out.println("What is the Question you need to study?");
- int c = 1 + 1;
- Question = Input.nextLine();
- System.out.println("What is the Answer to the Question?");
- Answer = Input.nextLine();
- System.out.flush();
- do {
- System.out.println(Question);
- System.out.println("What's the answer?");
- Panswer = Input.nextLine();
- if(Panswer.contentEquals(Answer)) {
- System.out.println("You're correct!! The answer is " + Answer);
- Flag = true;
- }else if(!Panswer.contentEquals(Answer)) {
- System.out.println("You're incorrect, the answer is " + Answer);
- Flag = false;
- }
- i++;
- do{
- if(i == Looptimes) {
- System.out.println("Do you want to continue?");
- Continue = Input.nextLine();
- if(Continue.contentEquals("Yes") || Continue.contentEquals("yes") || Continue.contentEquals("Yea") || Continue.contentEquals("Yeah") || Continue.contentEquals("Y") || Continue.contentEquals("y")) {
- Flag = false;
- }
- else if(Continue.contentEquals("No") || Continue.contentEquals("no") || Continue .contentEquals("N") || Continue.contentEquals("n") || Continue .contentEquals("Nope") || Continue.contentEquals("nope")) {
- System.out.println("Stopping Program");
- Flag = true;
- }else{
- System.out.println("Try Again!");
- }
- }
- } 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")))
- }while(Flag = false || i != Looptimes)
- Input.close();
- }
- }
- How many times do you want to study this question?
- 5
- What is the Question you need to study?
- What is the Answer to the Question?
- w
- What's the answer?
- w
- You're correct!! The answer is w
- Exception in thread "main" java.lang.NullPointerException
- at StudyIdea.main(StudyIdea.java:42)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement