Lab_03-OOP
Lab_03-OOP
Submission Profile
Name: Submission date (dd/mm/yy):
Enrollment ID: Receiving authority name and signature:
Comments:
__________________________________________________________________________
Instructor Signature
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
1
Note: Submit this lab handout before the next lab with attached solved activities and exercises
Objectives
This lab will help students apply fundamental Java concepts by implementing interactive games.
The following topics will be covered:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
2
📝 Lab Tasks
Each task provides a description, hints, and expected output.
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
3
2. The user is shown one question at a time, along with four answer choices (A, B, C, D).
3. The user inputs their answer (A, B, C, or D).
4. The program checks the answer:
o If correct, it displays "Correct!" and increases the score.
o If incorrect, it displays "Wrong!".
5. After all 5 questions, the program shows the final score.
Hints to Solve the Task:
• Use arrays to store questions and answers.
• Use a for loop to ask all 5 questions one by one.
• Use if-else conditions to check if the answer is correct or incorrect.
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
4
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
5
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
6
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
7
Expected Output:
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
8
Task 8: Find the Missing Number Game
The program stores a sequence of numbers with one missing number. The user must guess the
missing number to complete the sequence.
How It Works:
1. The program displays a sequence of numbers, but one number is missing.
2. The user is asked to guess the missing number.
3. The program checks if the guessed number is correct.
o If the guess is correct, it prints "Correct! The missing number was X."
o If the guess is incorrect, it prints "Wrong! The correct number was X."
Hints to Solve the Task:
• Use an array to store the sequence with one missing value.
• Use a loop to check where the missing number is.
• Use an if-else condition to verify the user’s guess.
Expected Output:
DEPARTMENT OF COMPUTER SCIENCE, SUKKUR IBA UNIVERSITY PREPARED BY: Moona Solangi
9