LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2012, 02:41 PM   #1
carlosk711
Member
 
Registered: Sep 2012
Posts: 52

Rep: Reputation: Disabled
Having trouble with program/figuring out error messages


So this is what I'm trying to do:
Code:
 Dice Poker is a two player game, where in each round both players roll a pair of 6-sided dice (2d6). The winner is determined according to the following rules:

If one player rolls a pair (two of the same kind), and the other player doesn't roll a pair, the person who did roll a pair wins.
If both players roll a pair, then the player with the highest pair wins. If both players roll the same pair, then it is a tie.
If neither player rolls a pair, then the person with the highest number wins.
If both players roll the same highest number, then the smaller number of each player is checked. The person with the largest smaller number wins.
If both players rolled the same numbers on both dice, it is a tie.

    Ask the user for the values of the dice for the first player.
    Ask for the values of the dice of the second player.
    If any of the integers are smaller than 1 or greater than 6, print out an error message and quit.
    Otherwise, determine who won the game and print out the winner of the game --- unless it is a tie, in which case the program will say it is a tie. Follow the output format below.
Code:
(THIS IS LINE 11)int winner( int, int, int, int);
bool range ( int, int, int, int);
int main ()
{
    int num1, num2, num3, num4;
    cout << "Welcome to dice poker!" << endl
    << "The first player just rolled. The dice have spoken."
    <<" What do his/ her dice say?" << endl;
    cin >> num1 >> num2 ;
    cout << "The second player is not far behind."
    <<" What do his/her dice say?" << endl;
    cin >> num3 >> num4 ;
    { if(
    bool ( num1, num2, num3, num4 ) == true
    (void winner (num1, num2, num3, num4 ));
    else
    cout << "One or more of the numbers in the input are out of range"
    << "Please use real dice next time." << endl;
    }
    return 0;
}

bool range ( int num1, int num2, int num3, int num4)
    {if(
    (num1 >= 1)&& (num1 <= 6) && (num2 >= 1) && (num2 <= 6)
    (num3 >= 1) && (num3 <=6) && (num4 >= 1) && (num4 <= 6))
    return true;
    else
    return false;
    }
int winner ( int num1, int num2, int num3, int num4)
{
    if
    ((num1 + num2) > (num3 + num4))
    cout << "Now I will determine your destiny: Player 1 wins!"
    << "Player 2 is now humiliated and might cry." << endl;
    else if
    ((num1 + num2) < (num3 + num4))
    cout << "Now I will determine your destiny: Player 2 wins!"
    << "Player 1 is now humiliated and might cry." << endl;
    else
    cout << "Now I will determine your destiny: Tie." << endl;
    }
and here is there errors, not much but still need help
Code:
project2.cpp: In function ‚int main()‚:
project2.cpp:24: error: functional cast expression list treated as compound expression
project2.cpp:25: error: expected primary-expression before ‚void‚
project2.cpp:25: error: ‚true‚ cannot be used as a function
project2.cpp:25: error: expected `)' before ‚;‚ token
project2.cpp: In function ‚bool range(int, int, int, int)‚:
project2.cpp:36: error: ‚(num2 <= 6)‚ cannot be used as a function
 
Old 10-04-2012, 07:03 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
This is marked as Solved, so presumably it is...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
logging messages from my program doesn't reach /var/log/messages rajas Programming 4 09-18-2011 12:38 AM
setting up new RH server, trouble figuring out partitions (naive about fdisk) eje4 Linux - Newbie 1 07-27-2009 07:21 PM
Postfix: User messages are okay; but error messages themselves seem to be bouncing jgombos Linux - Server 3 03-03-2007 02:21 PM
From where am i getting error messages to /var/log/messages? prabhuacsp Programming 3 02-16-2005 08:59 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration