Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HyrumDickinson/0c514c8da1dcbe121fdc38dd22af9b18 to your computer and use it in GitHub Desktop.
Save HyrumDickinson/0c514c8da1dcbe121fdc38dd22af9b18 to your computer and use it in GitHub Desktop.
Experimental gist (what even is this thing?)
import java.util.Scanner;
public class MultipleChoiceQuestionModifiable {
public static void main(String[] args) {
// this section provides the question content and may be modified
// modify the green inside the quotation marks to create a new question
// correctAnswer must be the same as one of the options
// options and correctAnswer must consist of a single lowercase word
String question = ("Who is the tallest Dickinson?");
String optionA = ("caleb");
String optionB = ("hyrum");
String optionC = ("ammon");
String optionD = ("nathanael");
String correctAnswer = ("hyrum");
// this section provides the question mechanics and should not be modified
System.out.println(question);
System.out.println(optionA + ", " + optionB + ", " + optionC + ", or " + optionD +"?");
Scanner input = new Scanner(System.in);
String userAnswer = input.next();
if (correctAnswer.equals(userAnswer.toLowerCase())) {
System.out.println("Good job! " + correctAnswer + " is the correct answer.");
} else {
System.out.println("Sorry, the correct answer was " + correctAnswer + ". Better luck next time!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment