Design a lotto class with one array instance variable


Assignment

Question I

Write the Java application that simulates a test. The test contains at least five questions about first three lectures of this course. Each question should be a multiple-choice question with 4 options.

Design a Test class. Use programmer-defined methods to implement your solution. For example:

i. create a method to simulate the questions - simulateQuestion
ii. create a method to check the answer - checkAnswer
iii. create a method to display a random message for the user - generateMessage
iv. create a method to interact with the user - inputAnswer

Display the questions using methods of JOptionPane class. Use a loop to show all the questions.

For each question:

i. If the user finds the right answer, display a random congratulatory message ("Excellent!","Good!","Keep up the good work!", or "Nice work!").

ii. If the user responds incorrectly, display an appropriate message and the correct answer ("No. Please try again", "Wrong. Try once more", "Don't give up!", "No. Keep trying..").

iii. Use random-number generation to choose a number from 1 to 4 that will be used to select an appropriate response to each answer.

iv. Use a switch statement to issue the responses, as in the following code:
switch ( randomObject.nextInt( 4 ) )
{
case 0:
return( "Very good!" );
......
}

At the end of the test display the number of correct and incorrect answers, and the percentage of the correct answers.

Your main class will simply create a Test object and start the test by calling inputAnswer method.

Question II

Design a Lotto class with one array instance variable to hold three random integer values (from 1 to 9). Include a constructor that randomly populates the array for a lotto object. Also, include a method in the class to return the array.

Use this class to simulate a simple lotto game in which the user chooses a number between 3 and 27. The user runs the lotto up to 5 times and each time the sum of lotto numbers is calculated. If the number chosen by the user matches the sum, the user wins and the game ends. If the number does not match the sum within five rolls, the computer wins.
Use methods of JOptionPane class to interact with the user.

Question III

Write a Java class that implements a set of three overloaded static methods. The methods should have different set of parameters and perform similar functionalities. Call the methods within main method and display the results.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Design a lotto class with one array instance variable
Reference No:- TGS03242065

Expected delivery within 24 Hours