Java - Fill in Question
Not what you're looking for?
Add a class FillInQuestion to the question hierarchy of How To 10.1. An object of this class is constructed with a string that contains the answer, surrounded by _ _, for example, "The inventor of Java was _James Gosling_". The question should be displayed as
The inventor of Java was _____
Here is a sample program run:
_____ was the inventor of Java.
Your answer:
James Gosling
true
The first U.S. president was _____
Your answer:
George Washington
true
Use the following class as your main class:
import java.util.Scanner;
public class QuestionDemo
{
public static void main(String[] args)
{
Question[] quiz = new Question[2];
FillInQuestion question0 = new FillInQuestion(
"_James Gosling_ was the inventor of Java.");
quiz[0] = question0;
FillInQuestion question1 = new FillInQuestion(
"The first U.S. president was _George Washington_");
quiz[1] = question1;
Scanner in = new Scanner(System.in);
for (Question q : quiz)
{
q.display();
System.out.println("Your answer: ");
String response = in.nextLine();
System.out.println(q.checkAnswer(response));
}
}
}
You need to supply the following class in your solution:
FillInQuestion
Purchase this Solution
Solution Summary
The solution assists with a Java fill-in question.
Purchase this Solution
Free BrainMass Quizzes
C# variables and classes
This quiz contains questions about C# classes and variables.
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.
Javscript Basics
Quiz on basics of javascript programming language.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.