Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why is it saying my function is undeclared with the first while statement with player2char? void play_game(int upper_bound); // REC'D: upper bound of guessing range

Why is it saying my function is undeclared with the first while statement with player2char? void play_game(int upper_bound); // REC'D: upper bound of guessing range // Function: get_guess // Asks the user for a guess, making sure that it is a valid guess */ int get_pick (int player_num); // REC'D: upper bound of guessing range //Function: user_wishes_to_continue //Returns: true (1) if the answer is yes or false (0) if answer is no int user_wishes_to_continue (); int main() { // 0. Seed the random number generator // time(0) returns the number of seconds since some date in the past // 1. Print program greeting // Function: print_greeting // starts the program printf ("Welcome to the RPS Game!"); printf ("Let's play! "); int num_matches; //number of matches int i; //lcv printf ("How many matches will be played? "); scanf ("%d", &num_matches); i < 0; while (i <= 1) printf (get_pick); // 2. Play the game until matches are done wishes to quit => i.e. at least once do { play_game(MAX_NUMBER); } while(num_matches < i); play_game(num_matches); return 0; } /* end main */ print_picks() { char input; //user's answer { int player1char; //recieved int player2char; //ask the user if they want to play again scanf (" %c", &input); input = toupper (input); //make input a uppercase letter while (player1char)(input == 'R'); { printf("Player 1 chose Rock "); } while (player1char) (input == 'P'); { printf("Player 1 chose Paper "); } while (player1char)(input == 'S'); { printf("Player 1 chose Scissors "); } while (player1char)(input != 'R' && input!= 'P' && input != 'S'); { printf("Player 1 chose Unknown "); } if (player2char)(input == 'R'); printf("Player 2 chose Rock "); } while (player2char) (input == 'P'); { printf("Player 2 chose Paper "); } while (player2char)(input == 'S'); { printf("Player 2 chose Scissors "); } while (player2char)(input != 'R' && input!= 'P' && input != 'S'); printf("Player 2 chose Unknown "); } } int get_pick(int upper_bound) { char player1char; //recieved char player2char; //received // 1. Ask for a pick printf (" Player 1, Pick (R)ock, (P)aper, or (S)cissors: "); scanf (" %c", &player1char); //lcv initialization statement //2.2 Ask again printf (" Player 2, Pick (R)ock, (P)aper, or (S)cissors: "); scanf (" %c", &player2char); //lcv update statement //2. check if the guess is in range [1... upperbound]and //reask until it is in range return get_pick; } void play_game(int upper_bound) { int target, // the number the computer picked guess; // the user's guess for the computer's number // 1. Computer picks a number. // 2. Ask the user for a guess until it is correct //user will make at least one guess, so use a do-while loop //Syntax: //do //{ // //} while (); do { guess = get_guess (upper_bound); //both init and update if (guess < target) printf("Player 1 wins! "); else if (guess > target) printf("Player 2 wins! "); else printf ("Tie! "); } while(guess != target); } /* end play_game */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

9. Mohawk Industries Inc.

Answered: 1 week ago