Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are asked to write a Java program for the electronic quiz system. The question will be displayed one by one. The user will enter

You are asked to write a Java program for the electronic quiz system. The question will be displayed one by one. The user will enter his/her answer, which is either A, B, C, or D. The system will then immediately check the answer and produce the result. After attempting all questions, the total score will be displayed. A sample run of the program is shown as below (Green text refers to user input):

Welcome to Astrology Test

Question 1: Which zodiac sign looks like a pair of fish?

A: Pisces

B: Aquarius

C: Libra

D: Virgo

Enter your answer (A, B, C, or D): A

Correct.

Question 2: Which of the following zodiac signs is called "the bull"?

A: Aries

B: Gemini

C: Leo

D: Scorpio

Enter your answer (A, B, C, or D): B

Incorrect. The correct answer is C

Question 3: How many signs are in the zodiac?

A: 6

B: 12

C: 14

D: 24

Enter your answer (A, B, C, or D): C

Incorrect. The correct answer is B

Question 4: What is the last sign in the astrological calendar?

A: Aries

B: Sagittarius

C: Pisces

D: Cancer

Enter your answer (A, B, C, or D): C

Correct.

Question 5: Which of these is not an air sign?

A: Gemini

B: Libra

C: Aries

D: Virgo

Enter your answer (A, B, C, or D): D

Correct.

Total score: 3 out of 5

Requirement:

  1. The output of the program MUST EXACTLY the same as the above sample run of in character level.
  2. You must create a class Question, which stores information of a question: the question text, the options, and the correct answer;
  3. You must create a class Asgn02, which has the main method to run the program.
  4. You must store all questions in an array and make use of this array throughout the program.
  5. You are NOT allowed to use other build-in data structures/classes like ArrayList, Set, HashMap, etc.

Input File Format:

All questions are stored in the file AstrologyQuiz.txt. The first line of the file indicates the number of questions in the file. Next, for every five consecutive lines, the first line refers to the question text, while the second to fifth lines refer to the four options. The true answer starts with a *, which should NOT be displayed in the system. The following shows a sample content of the file AstrologyQuiz.txt.

5

Which zodiac sign looks like a pair of fish?

*Pisces

Aquarius

Libra

Virgo

Which of the following zodiac signs is called "the bull"?

Aries

Gemini

*Leo

Scorpio

How

many signs are in the zodiac?

6

*12

14

24

What is the last sign in the astrological calendar?

Aries

Sagittarius

*Pisces

st Question

1

nd

2

Question

3

rd

Question

4

th

Question

Cancer

Which of these is not an air sign?

Gemini

Libra

Aries

*Virgo

5th Question

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

Recommended Textbook for

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions

Question

Describe obsessive-compulsive disorder.

Answered: 1 week ago