I need help with a C++ assignment:
Write a program containing the following:
1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement:
srand((unsigned int)time (NULL));
which will give the random number generator a random starting point.
Note: srand and rand require the TIME.H (or iomanip)
cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation.
2. Prompt the user for a whole number between 1 and 6.
3. Accept user input of the number – use Guess as the variable
4. Simulate rolling a die with the following code (DieRoll variable is defined in 1):
DieRoll = rand()%6+1; //Note: rand is a function returning 0 thru 32767.
5. Display Guess and DieRoll on the Screen with good user labeling information. Additionally, display”WINNER” if Guess and DieRoll are equal.
6. Display “DOUBLE WINNER” if DieRoll is an odd number (use modulo). Not related to question 5 above.
7. If the DieRoll added to the Guess is greater than or equal 10 and DieRoll is even Display “YOU ARE A LUCKY PERSON”. This is unrelated to the previous requirements.
8. Create a for loop to print the numbers 1 thru 5, all on the same line.
9. On the next output line create a for loop which will count backwards by 1’s from 100 to 0 (inclusive of 100 and 0) only displaying every number which is evenly divisible by 17.
10. Write a while loop to do the same as 9.
11. Write a do…while loop to:
a. ask the user for a number ( use the variable Guess).
b. get user input.
c. tell the user the remainder of dividing the number by 5 (modulo) even if result is 0.
d. continue the loop until the user enters zero (0) as the number. (Make sure the user is aware of this.)
Organize the loop like this (this is a planning technique called pseudocode):
prompt the user for a # (a. above)
get user input (b. above)
output to user (c. above)
}while (your test goes here to see if the number is 0);
12. Create a for loop within a for loop. The outer loop will count from 1 to 5. The inner loop will count from 1 to 6 and write the product of the outer loop counter multiplied by the inner loop counter, all on the same line with one tab (‘\t’) between. Between the loop ends put a line feed (endl or \n). The result should look like this:
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18 etc,