The application should have following features: Questions and Answers: Question
ID: 3641062 • Letter: T
Question
The application should have following features:
Questions and Answers:
Question
Answer
The smallest prime number?
2
Area of triangle with base = 4 and height = 3?
6
Area of square with side = 5?
25
Square root of 144?
12
No. of states in US?
50
No. of continents in the world?
7
In which year did man land on the moon?
1969
How many colors in a rainbow?
7
How many colors in the US flag?
3
Square of 25?
625
Question
Answer
The smallest prime number?
2
Area of triangle with base = 4 and height = 3?
6
Area of square with side = 5?
25
Square root of 144?
12
No. of states in US?
50
No. of continents in the world?
7
In which year did man land on the moon?
1969
How many colors in a rainbow?
7
How many colors in the US flag?
3
Square of 25?
625
Explanation / Answer
import java.util.Random; import java.util.Scanner; public class Test { public static void main(String[] args) { new QuizApplication().runQuiz(); } } class QuizApplication { private QuestionItem[] bank; private int score; private int numQuestions = 5; public QuizApplication(){ this.builQuestionBank(); } private void builQuestionBank() { bank = new QuestionItem[10]; bank[0] = new QuestionItem("The smallest prime number?", 2); // I added my own stupid questions to save time... bank[1] = new QuestionItem("Bla2?", 2); bank[2] = new QuestionItem("Bla3?", 2); bank[3] = new QuestionItem("Bla4?", 2); bank[4] = new QuestionItem("Bla5?", 2); bank[5] = new QuestionItem("Bla6?", 2); bank[6] = new QuestionItem("Bla7?", 2); bank[7] = new QuestionItem("Bla8?", 2); bank[8] = new QuestionItem("Bla9?", 2); bank[9] = new QuestionItem("Bla10?", 2); } public void runQuiz() { System.out.println("*********"); System.out.println("Welcome to my quiz!"); System.out.println("*********"); int i = 0; Random rand = new Random(); Scanner sc = new Scanner(System.in); while(iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.