Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the third photo is the lab 3 program.cpp Lizards fight in a rock-paper-scissors-like fashion. You will be writing a natural selection game by adding to

the third photo is the lab 3 program.cpp
image text in transcribed
image text in transcribed
image text in transcribed
Lizards fight in a rock-paper-scissors-like fashion. You will be writing a natural selection game by adding to the "Lab 3 Program.cpp" program, so that it executes as follows: 1) The user will enter a number 1-3 to select "orange", "blue", or "yellow". 2) The computer will select a number 1-3 randomly (The code to generate a random number and the required standard libraries are already included) 3) Determine who wins using if/else-if/else statements (Orange lizards beat blue lizards, blue lizards beat yellow lizards and yellow lizards beat orange lizards). Print the results to the console. 4) NOTE: It is possible for the player to win, lose, or tie 5) The result should include the player's selection and who won the match. 6) Make sure to check for bad numeric data. Terminate the program if the user selects an invalid number Sample Outputs Run 1: Natural Selection Game 1. Orange 2. Blue 3. Yellow Enter a number: 3 Blue beats yellow! You lose! E 18 Sample Outputs Run 2: Natural Selection Game 1. Orange 2. Blue 3. Yellow Enter a number: 7 ERROR - Invalid Input. Terminating Program. Sample Outputs Run 3: Natural Selection Game 1. Orange 2. Blue 3. Yellow Enter a number: 3 You both chose yellow! It's a tie! hun 03 V/TO-DO: Fill in the Authors Name Here W/TO-DO: Fill in the current date here V/CS1428 Lab //Lab 3 //Description: this program will allow the user to play a game of Orange, Yellow, Blue Lizard against a randomized computer opponent //****************This is the line of 80 characters in length 1/***** ****Your code should not exceed the length of the above line#************** #include include using namespace std; int main() int user num //user's choice int comp num; //computer's choice 1/ Generate the computer's choice randomly: srand(time(NULL)); compnum - rand() * 3 + 1; // Get the user's choice cout "Natural Selection Games and 1. Orange" ondt 2. Blue

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 Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions