card dealing assignment

This is my project im fairly new and found this and thought id try it, how wpuld i go about starting this program? this is a template and i have to finish the program using the comments below...please help

#include <iostream>
#include <ctime>
#include <string>

using namespace std;

//function prototypes
string GetSuit(); // get the card suit (clubs, spades, diamonds, hearts)
int GetFaceValue(); // return a number from 0 to 13 representing the value of the card
string ConvertToCard(int); // convert a number from 0 to 13 into ace, one, two, ..., queen, king

int main()
{
string suit;
int facevalue;
string card;
srand(static_cast<int>(time(0))); // seed the random number generator

cout << "This program will randomly generate 10 playing cards." << endl;
for (int i=1; i<=10; i++)
{
// Fill in the code required to set the variable suit to a random suit value
// by calling function GetSuit

// Fill in the code required to set the variable facevalue to a random number
// from 0 to 13 by calline function GetFaceValue

// Fill in the code required to set the variable card to a string that represents
// the actual card by calling function ConvertToCard and sending it facevalue

cout << "Card " << i << " is the " << card << " of " << suit << endl;
}

return 0;
}

string GetSuit()
{
int num;
string result;
num = (1 + rand() % 4);
switch (num)
{
case 1: result = "clubs";
break;
case 2: result = "spades";
break;
case 3: result = "diamonds";
break;
default: result = "hearts";
}
return result;

}

int GetFaceValue()
{

return rand() % 14;
}

string ConvertToCard(int v)
{
string result;
switch (v)
{
case 0: result = "ace";
break;
case 1: result = "one";
break;
case 2: result = "two";
break;
case 3: result = "three";
break;
case 4: result = "four";
break;
case 5: result = "five";
break;
case 7: result = "seven";
break;
case 8: result = "eight";
break;
case 9: result = "nine";
break;
case 10: result = "ten";
break;
case 11: result = "jack";
break;
case 12: result = "queen";
break;
default: result = "king";
}
return result;
}
Last edited on
Topic archived. No new replies allowed.