Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 12th, 2004, 09:50 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default need help with a program

I need help in writing a program that gives the roll of three different dice with numbers between 1 and 10 on them (two cant be the same number) then give the total of the three and ask if the next roll will be higher and lower. If they guess correct the game will keep going if not the game will end and give how many rounds they went and the probability they would get that far. Can anyone help me I know very little about programming and would greatly appreciate any help


Reply With Quote
  #2 (permalink)  
Old October 13th, 2004, 02:52 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi captlem66,
Quote:
quote:Originally posted by captlem66
 if not the game will end and give how many rounds they went and the probability they would get that far
I think the hardest step in your problem is to get the probability,
I think you should solve this,
the numbers of answers that the below equation could accept,
dice1+dice2+dice3<PreviousStep(if it is lower)
dice1+dice2+dice3>=PreviousStep(if it is higher)
PreviousStep is the total of three numbers on dices from the previous step and also 1<=dice1<=10 and 1<=dice2<=10 and 1<=dice3<=10 and also dice1!=dice2!=dice3....
I have some problem with the last statement(dice1!=dice2!=dice3)if they could also be the same(like the real world)I can solve this problem ....
maybe your meaning from getting the probability is something else ...
Did I guess your meaning correctly?


--------------------------------------------
Mehdi.:)
Reply With Quote
  #3 (permalink)  
Old October 16th, 2004, 12:05 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

ohh,sorry,I was just thinking I'm taking mathematics exam!!!
I forgot we have a computer and can use it!!!
Code:
a special syntax!!!
int sum:=0;
int pre=:PreviousStep;
For Dice1:=1 to 10
 For Dice2:=1 to 10
  For Dice3:=1 to 10
     if(dice1!=dice2!=dice3) & (dice1+dice2+dice3>=Pre)  then sum:=sum+1;
//sum is the naswer
now the probability is n(A)/n(S);
n(S)=10*9*8
n(A)=sum
so p(A)=n(A)/n(S)=sum/10*9*8.

--------------------------------------------
Mehdi.:)
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
C program Raj264264 BOOK: Professional C++ 3 March 29th, 2010 08:55 PM
Program to use for c# Doom C# 2005 2 January 4th, 2008 04:52 AM
What Program manih Assembly Language 1 December 1st, 2006 04:48 PM
Setup Project: Program not added in Start>Program arif_1947 VS.NET 2002/2003 2 March 31st, 2005 06:40 AM
Start a program inside another program Silje Classic ASP Professional 1 November 16th, 2004 02:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.