Browsing articles tagged with " paper"

How to write a game of JACK N POY or Scissors, Paper, Rock using TURBO C?

Dec 10, 2012   //   by   //   Blog  //  No Comments

Question by Iggy: How to write a game of JACK N POY or Scissors, Paper, Rock using TURBO C?
The input of player 1 should be hidden before player 2 can input.

Outputs should be like this

If Paper wins over rock “Paper covers rock”
if Rock wins over scissors “Rock breaks scissors”
if scissors wins over paper “Scissors cuts paper”
if draw “Nobody wins”

PS. I need the simplest code as possible. Thanks.

Best answer:

Answer by Nick T
You need to study in class and actually attempt your own homework.

PSEUDO CODE

DEFINE FUNCTION GetInput( Input Text as string ) returns character
..declare result as character value ‘ ‘
..LOOP WHILE ( result is no R S or P )
….output (text) (Rock, Scissors, Paper)
….input result
..END LOOP
..return result
END FUNCTION

MAIN ENTRY POINT
..declare Player1 as character value ‘ ‘
..declare Player2 as character value ‘ ‘
..Player1 = GetInput(“Player 1″)
..CLEAR SCREEN
..Player2 = GetInput(“Player 2″)
..CLEAR SCREEN
..IF( ( Player1 is Paper ) AND (Player2 is Rock) ) THEN output Paper covers Rock, Player 1 wins!
..ELSE IF( ( Player1 is Rock) AND (Player2 is Scissors) ) THEN output Rock breaks scissors, Player 1 wins!
..ELSE IF( ( Player1 is Scissors) AND (Player2 is Paper) ) THEN output Scissors cuts paper, Player 1 wins!
..ELSE IF( ( Player2 is Paper ) AND (Player1 is Rock) ) THEN output Paper covers Rock, Player 2 wins!
..ELSE IF( ( Player2 is Rock) AND (Player1 is Scissors) ) THEN output Rock breaks scissors, Player 2 wins!
..ELSE IF( ( Player2 is Scissors) AND (Player1 is Paper) ) THEN output Scissors cuts paper, Player 2 wins!
..ELSE output Its a Draw!
END MAIN

Add your own answer in the comments!

Pages:1234567...14»

Disclaimer

We are not a professional review site, however, we receive compensation from the companies whose products we promote or review. We are independently owned and the opinions expressed here are our own.

RSS News

StatPress

Visits today: 27