Download presentation
Presentation is loading. Please wait.
Published byΕυαδνη Δουρέντης Modified over 6 years ago
1
GROUP 2 SARAH ELEENA MOHD USLI NURUL AIDIL ABD HALIM
NOOR SALBANIAH JALALUDDIN SITI FARAH SHAMSUDDIN RAFIQQAH MUHAMAD SABRI SITI ZALIHAR ABD MUTALIB
2
QUESTION 2 Write a program for a guessing game. The program will randomly select a number between 1 and 100. The user is asked to guess a number. - if the guess is higher, print “The number is higher than that. Try again !” or other related msg. - if the guess is lower, print “The number is lower than that. Try again !” or other related msg. - if the guess is correct, print “Congratulation! You guess it correctly !” or other related msg. If the user guessed wrongly for 10 times, the game ends with “game over!” or other related msg. If the user is able to guess the number correctly, asks for the user’s name and store it in a file. The name will be displayed each time the program starts.
3
PSEUDOCODE OPEN FILE ‘mz1’ READ RECENT WINNER’S NAME CLOSE FILE
GET FIRST GUESSING NUMBER LOOP FROM 1 TO 9 AS ‘W’ IF i != r , EXIT IF i > r ,PRINT NUMBER IS HIGH IF i < r ,PRINT NUMBER IS LOW IF i == r , PRINT CONGRATULATIONS GET WINNER’S NAME APPEND WINNERS NAME END LOOP
4
FLOW CHART
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.