how to write this program?

hello

i have a q

two players play a game of tossing dies and the sum of the two appeared numbers will determine the winner . the sum of the two numbers will be in the range from 2 to 12 because every face of the dies begin with 1 and endes with 6 . the player win if the sum of the two appeared numbers 7 or 11 , he loses if the sum is 12 or 3 or 2 . but if the sum of the two numbers is 4 or 5 or 6 or 8 or 9 or 10 he will get a point , he repeat until he win with points ( if he get 20 points ) or lose if he get 7 . write a pseudo code for this game

the code should be with loops

what i tried to do is this:




#include<iostream.h>
main()
{
int x,y,z,j,sum=0;

cout<<"enter your appeared number\n";
cin>>x>>y;
for(j=2;j<=12;j++)
j=x+y;
{
if(j=='7'||j=='11'||j=='20')
cout<<j<<"you win";}
else
{if(j=='12'||j=='3'||j=='2')
cout<<j<<"you lose";}
else
if(j=='4'||j=='5'||j=='6'||j=='8'||j=='9'||j=='10')
{sum+=j;
cout<<sum<<"you got a point";

}
}




i know it is wrong so can you help with it because i am new in the c++

thank you
Well, first of all is this the direction you want to go? Wouldn't you rather generate random die rolls with rand()? Aside from the design problem you have j == '9' or whatever number, which is actually not the number 9, but somwhere around 57. So none of your ifs will function correctly.
Why don't you just ask how to write a craps program?
As Return 0 said you don't have number 9 there you have '9' ,which is a char or something..And it is better to have a random generators for dice,cause you don't want to throw them and just input what you get.I'd suggest you go back to the idea of this thing.Then just remove ' ' from every number.
i agree with them, for dice games it is better to have a random generator, makes the game more interesting and yes having the
'9'
won't check for the number 9, i have no idea what it will check for, but it does look like a char as genesys said.
Topic archived. No new replies allowed.