Find Jobs
Hire Freelancers

Guessing Game #0

$15-20 USD

Concluído
Publicado há mais de 21 anos

$15-20 USD

Pago na entrega
Write a program that allows the user to play guessing games. A guessing game is where the computer generates a random number and the user tries to guess it. The program loops until the user guesses the random number, or enters a sentinel value to give up. After five wrong guesses, the user is given help (higher or lower messages). After a game has been completed, the program asks the user if they want to play again. The user is allowed to play at most 256 games. Prior to terminating program, print the following. number of games played number of games won winning percentage At the end of your program should be a comment block that contains the pseudo-code for your program. This program must be split into at least three functions. Required Manifest Constants Your program must define the following manifest constants prior to the definition of the main() function (i.e. make these global): const int MIN_NUMBER = 1; const int MAX_NUMBER = 100; const int EXIT_VALUE = -1; const int MAX_GAMES = 256; Generating a Random Number Include the time.h header file. To generate a random number that ranges between MIN_NUMBER and MAX_NUMBER (inclusive), use code similar to the following: srand(time(NULL)); randomNumber = MIN_NUMBER + rand() % (MAX_NUMBER - MIN_NUMBER + 1); The time() function returns the current date and time in seconds since 01-Jan-1970 00:00:00 GMT. Passing this return value to srand() "seeds" the random number generator so that a different set of random numbers are generated every time the program is executed. The rand() function returns a random number between 0 and RAND_MAX (a manifest constant defined in stdlib.h). ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Example Game: Assume the computer generated random number is 34 for game #1, 73 for game #2, and 99 for game #3. For example purposes, user inputs are enclosed in brackets <>. *** You are playing the CIS162 Guessing Game *** Enter a number between 1 and 100 (-1 to give up): <3> nope... Enter a number between 1 and 100 (-1 to give up): <1001> 1001 is too big... Enter a number between 1 and 100 (-1 to give up): <0> 0 is too small... Enter a number between 1 and 100 (-1 to give up): <33> nope... Enter a number between 1 and 100 (-1 to give up): <50> nope... Enter a number between 1 and 100 (-1 to give up): <21> nope... Enter a number between 1 and 100 (-1 to give up): <41> nope... Enter a number between 1 and 100 (-1 to give up): <27> nope...higher Enter a number between 1 and 100 (-1 to give up): <57> nope...lower Enter a number between 1 and 100 (-1 to give up): <34> *** GOT IT *** it took you 8 guesses Do you want to play again? (y/n): Enter a number between 1 and 100 (-1 to give up): <99> nope... Enter a number between 1 and 100 (-1 to give up): <-1> *** QUITTER *** Do you want to play again? (y/n): Enter a number between 1 and 100 (-1 to give up): <21> nope... Enter a number between 1 and 100 (-1 to give up): <99> *** GOT IT *** it took you 2 guesses Do you want to play again? (y/n): Thanks for playing the CIS162 guessing game. You played 3 games and won 2 of them. Your winning percentage is 66.7%. ## Platform Windows XP
ID do Projeto: 2889230

Sobre o projeto

4 propostas
Projeto remoto
Ativo há 21 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
See private message.
$12 USD em 14 dias
5,0 (65 avaliações)
4,7
4,7
4 freelancers estão ofertando em média $10 USD for esse trabalho
Avatar do Usuário
See private message.
$8,50 USD em 14 dias
5,0 (8 avaliações)
2,3
2,3
Avatar do Usuário
See private message.
$11,05 USD em 14 dias
4,8 (2 avaliações)
0,3
0,3
Avatar do Usuário
See private message.
$7,65 USD em 14 dias
0,0 (1 avaliação)
0,0
0,0

Sobre o cliente

Bandeira do(a) FRANCE
France
5,0
27
Membro desde out. 13, 2002

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.