Skip to content

Repository files navigation

COMP228 - LAB2 ASSIGNMENT README FILE 🚀

This repository contains Java solutions for three exercises designed to enhance your programming skills. Below you'll find descriptions of each exercise along with instructions on how to run the programs.

Exercise 1: Test Simulator

In this exercise, you'll find a Java application that simulates a test. It includes the following features:

  • Five multiple-choice questions based on the first three lectures of the course.
  • A Test class with programmer-defined methods for simulating questions, checking answers, generating messages, and interacting with the user.
  • Questions displayed using the JOptionPane class.
  • Random congratulatory or corrective messages for user responses.
  • Display of correct and incorrect answers, along with the percentage of correct answers at the end of the test.

To run the test simulator, simply create a Test object and start the test by calling the inputAnswer method from the main class.

Exercise 2: Lotto Game

In this exercise, you'll find a Lotto class designed to simulate a simple lotto game. Here's what it includes:

  • The Lotto class with an array instance variable to hold three random integer values between 1 and 9.
  • A constructor that randomly populates the array for a Lotto object.
  • A method to return the array.
  • Interaction with the user using JOptionPane methods.

To play the lotto game, the user chooses a number between 3 and 27. The lotto runs up to 5 times, and each time the sum of the lotto numbers is calculated. If the user's chosen number matches the sum, the user wins; otherwise, the computer wins if there's no match within five rolls.

Exercise 3: Overloaded Methods

This exercise involves writing a Java class with three overloaded static methods. Here's what it includes:

  • Three overloaded static methods with different sets of parameters performing similar functionalities.
  • Calling these methods within the main method and displaying the results.

To run this exercise, simply call the methods within the main method and observe the results.

Running the Programs

To run each exercise:

  1. Compile the Java files.
  2. Execute the compiled files, ensuring that you have Java installed on your system.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages