| | |
code help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2005
Posts: 5
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
using dice std; # include <cstdlib> int dice( ) { int. random_ interger = rand ( ) cout << random_ interger << end 1 }
. Write the member function definitions for each function listed:
1. Object Type: a pair of dice
Knows:
The value of each face (1 – 6)
Can Do:
Roll for new face values
Tell the value on each face.
Initialize the die to have a value of 1 on each face. To roll the die, use the rand() function, to generate a random number. In order to generate a random number between 1 and 6, use the following:
Number = rand() % 6 + 1;
rand() is located in <cstdlib>
As much as I want to help you, it looks like you want someone else to do your work for you. The code you've provided doesn't even come close to an attempt to solve the problem. It's asking you to write a Dice class that supports rolling the dice and giving the result. If you're having trouble with C++ at the fundamental level as your code suggests, you really need personal, face to face help instead of the clipped "this is your problem, here's how to fix it" help that you'd get here.
And no, nobody is going to write this for you.
And no, nobody is going to write this for you.
•
•
•
•
Originally Posted by t3bruce
<< moderator edit: added [code][/code] tags >>C++ Syntax (Toggle Plain Text)
using dice std; # include <cstdlib> int dice( ) { int. random_ interger = rand ( ) cout << random_ interger << end 1 }
. Write the member function definitions for each function listed:
1. Object Type: a pair of dice
Knows:
The value of each face (1 – 6)
Can Do:
Roll for new face values
Tell the value on each face.
Initialize the die to have a value of 1 on each face. To roll the die, use the rand() function, to generate a random number. In order to generate a random number between 1 and 6, use the following:
Number = rand() % 6 + 1;
rand() is located in <cstdlib>
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Code 19 Registry Error (Windows NT / 2000 / XP)
- Why won't this code work? (VB.NET)
- Need help with DirectX code (C)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the C++ Forum
- Previous Thread: Defining structure for a scenarios
- Next Thread: c++ help
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






