? asked in Computers & InternetSoftware · 1 decade ago

help with this program please.....?

Question A

You are required to create a game that will operate as follow

• The player will guess a number between 1 and 9

• The computer will then select a random number between 1 and 9

• The program will then compare the two numbers and if they are equal the player wins and his/her score is increased by 1. if they are not equal the computer score is increased by 1.

• The player can exit the game by entering -1. when this occurs the players score and the computer score is displayed on the screen and the overall winner is congratulated via an appropriate message on the screen.

Question B

You are required to modify the above game so that instead of guessing numbers the player will guess a three letter word. You are required to ensure that the word enter has only three characters, otherwise allow the user to try again. You are required to create an array of string of size 10 of with three letter words will displayed to the user at the beginning of the game from which the player will select a word.

The word selected by the player and the one selected by the computer will be compared and the scoring is done similar to the one above. In case however, allow the user enter the number of times they desire to run the program.at the end of the game display the computer’s score and the player’s score and congratulation message to the overall winner.

Update:

its a c program

Update 2:

IT IS A C PROGRAM AND GUYS I ONLY HAVE THIS JUST HELP ME PLEASE WITH YOUR KINDNESS PLEASE....

int num, user=o, com=0, guess;

guess

do

printf("to see score enter '-1'\n\n");

printf("enter any number from 1-9:");

scanf("%d",&num):

system("cls");

if(num ==1)

{

break:

}

if(num !=guess)

Update 3:

jiji thnx with part A...ur so kind.......but if u could help with part b it would be even more lovely.....

4 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    this is easy but what language are you asked to write it in ? C? Python? PASCAL?

    I can write you the codein C but that's not the right way, at least try it!

    Anyway here is the answer for the first, the second is basically the same but more complicated because you will be working with strings

    #include <stdio.h>

    #include <stdlib.h>

    #include <time.h>

    #include <stdio.h>

    #include <stdlib.h>

    #include <time.h>

    int main ( int argc, char** argv )

    {

    int mysteryNumber = 0, numberEnterd = 0, userScore=0, compScore=0;

    const int MAX = 9, MIN = 1;

    do

    {

    printf("Guess a number between 1 and 9? ");

    scanf("%d", &numberEnterd);

    // Generate the Mystery Number

    srand(time(NULL));

    mysteryNumber = (rand() % (MAX - MIN + 1)) + MIN;

    if (mysteryNumber == numberEnterd)

    { userScore++;

    printf("yes that's it, your score now is %d and the computer's score is %d\n", userScore, compScore);

    }

    else if (mysteryNumber != numberEnterd)

    { compScore++;

    printf("no that's not it, your score now is %d and the computer's score is %d\n", userScore, compScore);

    }

    } while (numberEnterd != 0);

    printf("the user score is %d and the computer score is %d\n", userScore, compScore);

    if(userScore>compScore)

    printf("Congrats Mr. User you win\n");

    else if(compScore>userScore)

    printf("Congrats Mr. Computer you win\n");

    else

    printf("Congrats for both of you!\n");

    }

    I didn't test it so they might be some errors. And I took 0 instead of -1

  • 4 years ago

    software has grow to be the traditional for computing. Programme is the unique British spelling - the two would be utilized by applying human beings - different than that bill Gates' spellchecker will stop you.

  • 1 decade ago

    no one is doing your homework. you can post this question for the third time when you have some code at least.

  • 1 decade ago

    It would really depend on what programming language you are using.

Still have questions? Get your answers by asking now.