eed in C++ without using Do loop!
Play the rock paper scissors game. Two players enter either rock, paper, or scissors and the winner is determined as follows:
paper covers rock
rock breaks scissors
scissors cut paper.
Ask the user if s/he wants to play again. BE SURE to include a function called play as shown in the template.
Sample run:
Play rock, paper, scissors
Player 1: rock
Player 2: paper
Player 2 wins -- Paper covers rock
Do you want to continue? (yes or no): yes
Player 1: scissors
Player 2: rock
Player 2 wins -- Rock breaks scissors
Do you want to continue? (yes or no): no
NOTE:
You must include a function called play which plays the game and returns
Define stubs for the functions called by the below main(). Each stub should print "FIXME: Finish FunctionName()" followed by a newline, and should return -1. Example output:
FIXME: Finish GetUserNum()
FIXME: Finish GetUserNum()
FIXME: Finish ComputeAvg()
Avg: -1
#include
using namespace std;
STUDENT CODE HERE
int main() {
int userNum1 = 0;
int userNum2 = 0;
int avgResult = 0;
userNum1 = GetUserNum();
userNum2 = GetUserNum();
avgResult = ComputeAvg(userNum1, userNum2);
cout
return 0;
}
Ask the user for a number between 3 and 100 (inclusive). USING LOOPS, figure out what is the largest power of 2 that is less than or equal to the number entered. For example, if the user entered 6, answer would be 4. If the user entered 100, the answer would be 64. You must do this within a function called powerOfTwo. For example:
Please enter a number from 3 to 100: 100
The answer is 64
#include
#include
using namespace std;
/* Type your code here. */
int main()
{
int num;
cout cin >> num;
cout if ((num 100))
cout else {
int answer = powerOfTwo(num);
cout }
}
Ask the user for a number between 2 and 1000. Using a loop, calculate the
integer square root
by calculating the square of every number from 1 until the square of the number is more than the number entered. The previous number is the integer square root. You must write a function called intSqrRoot which calculates the answer and
returns
it to main. See the template given. Sample run:
Please enter a number between 2 and 1000: 16
[1][1][2][3]
The integer square root of 16 is 4.
The numbers in the square brackets are intermediate values.
#include
using namespace std;
/* Type your code here. */
int main()
{
int num;
cout cin >> num;
cout if ((num 1000))
cout else {
int answer;
answer = intSqrRoot(num);
cout cout cout cout cout cout }
}
Get answer