Dice Roll prediction.

Guys please help me on this one.

Write a program that asks a user to predict how many rolls of a single die it will take to reach 100. When all rolling is finished, compare the given answer to the results and let them know if they did well or not.


Functionality
• First, ask the user to make a prediction – how many rolls will it take to reach 100?
• Now, start the rolling process. Remember, the die is six sided so each roll could result in any integer from 1 – 6 inclusively.
• After each ‘roll’, show the user the results of each die roll on a separate line. Tab over and display the running total.
• When the total reaches 100 or more, stop rolling.
• Let the user know how many rolls it took.
• Give a message using the following ranges:
o +/- 5 rolls – amazing!
o +/- 10 rolls – good.
o +/- 15 rolls – okay.
o +/- 20 rolls – think harder next time.

this is what i have so far.

#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;


const int SCORE_LIMIT = 100;
int diceroll, guess, result, total;

cout << " How many rolls will it take to reach 100? "<<endl;
cin >> guess;

int die = 1 + rand()%6 ;

do
{
total >= 100
cout << " You win"<<endl;

if(rolls = 1)


}while(total < 100);

if(rolls == 1)
{
cout << "You rolled a 1." << endl;

// This is what i have do far. i dont know what to do next.


system("PAUSE");
return EXIT_SUCCESS;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
	srand(time(0));
	const int score_limit = 100;
	int roll = 0, guess = 0, result = 0 , total = 0;

	cout << "How many rolls will it take to get to 100?\n";
	cin >> guess;
	
	do{
		
		roll =  1 + rand() % 6; // Edit: oops was accidentally rand() % 6 
		total = total + roll;
		result++;
		cout << result << "\t" << roll << "\t" << total <<  endl;
	} while (total < 100);

	

	if (guess - result <= 5)
		cout << "Amazing try!";

	else if (guess - result > 5 && guess - result < 10)
		cout << "Good try!";

	else if (guess - result > 10 && guess - result < 15)
		cout << "Better try harder";

	else if (guess - result > 15 && guess - result < 20)
		cout << "Did you even try?";

	else
		cout << "You're terrible";

	system("pause");
	return 0;
}


Don't wholeheartedly take this example and use it in its entirety.

Instead, look over this code and understand it and try and rewrite it on your own

Also RESULT should probably be something more or less like "Roll Number ---" but I didn't feel like changing all the occurrences ( though I'm sure there is an easy way to do so :) )
Last edited on
Thanks, i really appreciate it. And yes i will try it 100 times until i get it, i promise. God bless.
No problem, I'm new to coding ( sorta kinda eh idek ) -- I like the challenge of a new problem ( one that isn't super complex and beyond my understanding level )

There are probably parts of the code that I could rewrite to be more functional
You could add a loop to ask if they want to try again, etc, etc but I felt that this was sufficient enough to solve all the requirements of the problem.
Topic archived. No new replies allowed.