Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can somebody explain to me why the output isn't showing how many questions the user got right or wrong? I know the fun facts are

Can somebody explain to me why the output isn't showing how many questions the user got right or wrong? I know the fun facts are all the same at the moment. Just can't figure out the part where it won't output the amount of correct answers.

import java.util.Scanner;

public class AssignmentAttempt {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Welcome to Tamriel!");

System.out.println("What is your name traveler?:");

String entrdname = scan.nextLine();

System.out.println(entrdname);

System.out.println("Huh... not exactly what I imagined it would be.");

System.out.print("Regardless, thank you for the information, ");

System.out.print(entrdname);System.out.println(".");

System.out.println(" To make sure that you are stable enough to continue your journeys without further assistance, I will give you a short quiz.");

String answer1 = "";

String answer2 = "";

String answer3 = "";

String answer4 = "";

String answer5 = "";

int correctAnswers = 0;

do {

System.out.println("Where do you first start in Runescape?");

System.out.println("A: Paris");

System.out.println("B: Al Kharid");

System.out.println("C: Lumbridge");

System.out.println("D: Tutorial Island");

answer1 = scan.nextLine().toUpperCase();

if(!answer1.equals("D")) {

System.out.println("Invalid response, please try again.");

}

} while(!answer1.equals("D"));

System.out.println("Good job, that's correct!");

do {

System.out.println("Who is the development team behind Runescape?");

System.out.println("A: Square Enix");

System.out.println("B: Activision");

System.out.println("C: Jagex");

System.out.println("D: Blizzard");

answer2 = scan.nextLine().toUpperCase();

if(!answer2.equals("C")) {

System.out.println("Invalid response, please try again.");

}

} while(!answer2.equals("C"));

System.out.println("Good job, that's correct!");

do {

System.out.println("How many versions of Runescape have there been?");

System.out.println("A: Three");

System.out.println("B: Two");

System.out.println("C: One");

System.out.println("D: None :)");

answer3 = scan.nextLine().toUpperCase();

if(!answer3.equals("A")) {

System.out.println("Invalid response, please try again.");

}

} while(!answer3.equals("A"));

System.out.println("Good job, that's correct!");

do {

System.out.println("What month and year is the Old School Runescape version based on?");

System.out.println("A: March, 2004");

System.out.println("B: September 2008");

System.out.println("C: August 2007");

System.out.println("D: April 2000");

answer4 = scan.nextLine().toUpperCase();

if(!answer4.equals("C")) {

System.out.println("Invalid response, please try again.");

}

} while(!answer4.equals("C"));

System.out.println("Good job, that's correct!");

do {

System.out.println("What year did classic Runescape servers get shut down?");

System.out.println("A: 2009");

System.out.println("B: 2018");

System.out.println("C: 2020");

System.out.println("D: 2005");

answer5 = scan.nextLine().toUpperCase();

if(!answer5.equals("B")) {

System.out.println("Invalid response, please try again.");

}

} while(!answer5.equals("B"));

System.out.println("Good job, that's correct!");

if (answer1.equals("D")) {

correctAnswers++;

} else {

System.out.println("Question 1: You answered " + answer1 + ", but the correct answer was D. Fun fact: Tutorial Island is a tutorial island that introduces new players to the game.");

}

if (answer2.equals("C")) {

correctAnswers++;

} else {

System.out.println("Question 2: You answered " + answer2 + ", but the correct answer was D. Fun fact: Tutorial Island is a tutorial island that introduces new players to the game.");

if (answer3.equals("A")) {

correctAnswers++;

} else {

System.out.println("Question 3: You answered " + answer3 + ", but the correct answer was D. Fun fact: Tutorial Island is a tutorial island that introduces new players to the game.");

if (answer1.equals("C")) {

correctAnswers++;

} else {

System.out.println("Question 4: You answered " + answer4 + ", but the correct answer was D. Fun fact: Tutorial Island is a tutorial island that introduces new players to the game.");

if (answer1.equals("B")) {

correctAnswers++;

} else {

System.out.println("Question 5: You answered " + answer5 + ", but the correct answer was D. Fun fact: Tutorial Island is a tutorial island that introduces new players to the game.");

System.out.println("You got " + correctAnswers + " out of 5 questions correct.");

if (correctAnswers == 5) {

System.out.println("Wow, you're a master of Runescape!");

} else if (correctAnswers >= 3) {

System.out.println("Not bad, but you still have room for improvement.");

} else {

System.out.println("Well, that wasn't good.");

}

}

}

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions