i'm creating a dice game where you start off to enter how many rolls you want and then you enter a player name and then the rolls occure. after that you will be able to enter an other name and when you want to finnish you are supposed to enter none as player name to get the text who won but i'm stuck after that i have entered the first name and the rolls occur and none works as well but i don't get the sum of th dice throws to work and i'm not sure what i should write when
i want to show who has rolled highest
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main()
- {
- string none="none";
- string playername;
- int dicethrow;
- int howmany=0;
- int sumofdicethrows=0;
- srand((int)time(NULL));
- cout<<"How many dice throws? "<<howmany;
- cin>>howmany;
- while(playername!=none)
- {
- cout<<"player name"<<playername;
- cin>>playername;
- if (playername==none)
- {
- cout<<"competition is over";
- }
- else if (playername!=none)
- {
- for (int i=1; i<=howmany;i++)
- {
- dicethrow=rand()%6+1;
- cout<<dicethrow<<" ";
- sumofdicethrows=dicethrow;
- }
- }
- }
- return 0;
- }
best regards fredde