Ask C/C++ Expert


Home >> C/C++

Part 1-

switch

Create the first part of a Rock, Paper, Scissors game.  Tell the user what you are playing and then ask them to choose either rock, paper or scissors.  After they choose tell them what they chose.  If they make an invalid choice, let them know.  You must use a swich statement for this lab.

Your text must exatly match the examples below:

Example 1 with correct input:

Let's play Rock, Paper, Scissors

Enter 1 for rock, 2 for paper, 3 for scissors

2

You chose paper

Example 2 with incorrect input:

Let's play Rock, Paper, Scissors

Enter 1 for rock, 2 for paper, 3 for scissors

5

5 is not a valid choice

Part 2-

Create the second part of a Rock, Paper, Scissors game.  Alter lab 6 so that the user keeps playing as long as they enter in 'Y'.  Make this case sensitve; if they enter in lower case y the game will not continue.  If the user enters in anything besides upper case Y the game will end. 

Your text must exatly match the examples below:

Example 1 with correct input:

Let's play Rock, Paper, Scissors

Enter 1 for rock, 2 for paper, 3 for scissors

2

You chose paper

Would you like to play again (Y for yes, N for no)?

Y

Enter 1 for rock, 2 for paper, 3 for scissors

1

You chose rock

Would you like to play again (Y for yes, N for no)?

N

Example 2 with incorrect input:

Let's play Rock, Paper, Scissors

Enter 1 for rock, 2 for paper, 3 for scissors

5

5 is not a valid choice

Would you like to play again (Y for yes, N for no)?

y

Part 3-

The purpose of this project is to use cin to handle user keyboard inputs, use branching statements to control the flow of a program, and work on your C++ programming style.

You will implement a rock-paper-scissors game. The computer will select rock, paper, or scissors randomly (and of course not reveal this selection to the player). The player will then enter 1 for Rock, 2 for Paper, or 3 for Scissor. The program will let the player know if she or he won. At the end of each round ask the player if she or he wants to play again.

You must implement/include the following features in addition to the game play:

  • Keep count of the number of times the player won and lost -- when the player chooses to stop playing, display these counts
  • Keep a count of the number of times the player selects to play rock, scissors, and paper 
  • Implement the computer's selection as a random integer 

Objectives:

  • Work on your C++ programming style
  • Use boolean expressions
  • Use branching statements to control the flow of a program

Requirements:

  1. Source code is documented correctly with name, lab section, and name of program
  2. Your program source code must be neatly and consistently formatted (use GG=g in vim)
  3. Program compiles and runs without error
  4. Program handles user input with cin
  5. Use at least one (1) switch statement and one (1) if statement
  6. Computer generates an integer random selection
  7. Prompt for and read in the player's selection
  8. Compare the player's selection to the computer's selection
  9. Display an appropriate message to the player to let them know whether they won or lost 
  10. Keep a count of the number of times the player selects to play rock, scissors, and paper
  11. Prompt for and read in the player's choice about playing another round
  12. At the end of play, display the number of player wins and losses

13. Out of all the games played let the player know who was the overall winner (computer or player).  Also what the winning object (what object did the winner have the most wins with).

14. Tell the player what they should have chosen to win most of the time.  For example, if the computer chose rock 7 out of the 10 times then the player should have chosen rock to win most of the time.

part 4- Question 1

1. 1: for(int var=0; var<10; ++var)
2: {
3: cout << "Hi there" << endl;
4: }
5: cout << "After loop ends" << endl;

What is the value of var on line 5?

11

0

9

10

Question 2

1. How many times does this loop iterate?
1: int x = -5;
2: while( x > 4 )
3: {
4: cout << "hi there" << endl;
5: }
6: cout << "done!" << endl;

8

0

1

2

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91372762
  • Price:- $60

Guranteed 36 Hours Delivery, In Price:- $60

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As