forked from onyudo/intro_pscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient-a.txt
More file actions
35 lines (28 loc) · 1.06 KB
/
Copy pathclient-a.txt
File metadata and controls
35 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Client Task A #
# Add your pseudocode to this file below this line: #
# ------------------------------------------------- #
START
// Step 1: Initialize the game
SET random_number = RANDOM(1, 10) // Computer chooses a random number between 1 and 10
SET attempts = 3 // Number of attempts allowed
SET guessed_correctly = FALSE // Flag to track if the guess is correct
// Step 2: Game loop
WHILE attempts > 0 AND guessed_correctly IS FALSE DO
// Step 3: Get user input
OUTPUT "Guess a number between 1 and 10:"
INPUT user_guess
// Step 4: Check the guess
IF user_guess EQUALS random_number THEN
OUTPUT "Congratulations! You've guessed the number!"
SET guessed_correctly = TRUE
ELSE
// Decrease the number of attempts
SET attempts = attempts - 1
IF attempts > 0 THEN
OUTPUT "Incorrect. You have " + attempts + " attempts left."
ELSE
OUTPUT "Sorry! You've run out of attempts. The number was " + random_number + "."
END WHILE
// Step 5: End of game
OUTPUT "Thank you for playing!"
END