C Program Help - Rock, Paper, Scissors

Discussion in 'Software' started by eidtelnvil, Mar 28, 2005.

  1. eidtelnvil

    eidtelnvil Private E-2

    I know next to nothing about C programming and need to develop a simple program to play rock, paper, scissors.

    The choices need to be:
    1 - Explain the rules
    2 - Play the game
    3 - Quit

    The computer needs to prompt the user to enter a choice. When they play the game, the computer selects its own rock, paper, or scissor. Then the computer displays the results of the game. The game continues until the user selects 3 to quit.

    I know this is probably the easiest program imagineable, but I barely have time to do it. I have to have knee surgery on Wednesday and I don't know where to even begin. If anyone can point me in the right direction, I will sing your praises for all eternity.

    Thanks in advance.
     
  2. QuickSilver

    QuickSilver Corporal

    What sort of C programming experience do you have? Do you understand loops, if statements??? Character input and character comparisons... I mean a lot of people can point you in the right direction here to get you thinking along the right lines but I don't think many people will just fire out the code for you to use...

    So to break this down the program needs to...

    ask the user to enter a number
    based on that number either
    1 - Display the rules
    - Return to menu
    2 - pick a random paper/scissors/stone
    - prompt the user to enter paper scissor or stone
    - work out which is better (if comp has paper and user has stone then comp wins etc etc)
    - Return to menu
    3 - Exit

    I would possibly be tempted to get the computer to pick a number and random between 1 and 3 inclusive and then have a hard coded relationship between the number and a paper/scissor/stone... (1 = Paper, 2=Scissor, 3=Stone) and also to minimise potential errors I would have a menu after the user presses 2 another menu appears asking them to enter another choice between 1 and 3 based on what they want... eg displaying

    Which Item do you want?
    1 - Paper
    2 - Scissor
    3 - Stone
    Enter your choice :

    The rules to determine who wins are going to be some simple nested if/else statements...

    That personally is how I would implement that... give it a go yourself and see how you get on... Good luck.
     
    Last edited: Mar 29, 2005
  3. eidtelnvil

    eidtelnvil Private E-2

    Thanks much.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds