Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help in fixing this and submit thru zybooks C++ INPUT: No 6 5 i am getting Exited with return code -9 (SIGKILL). Enter seed

Need help in fixing this and submit thru zybooks C++image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

INPUT:

No 6 5

i am getting

Exited with return code -9 (SIGKILL).

Enter seed value:

Enter hand size:

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
//Card interface file //Card.h// #ifndef CARD H #define CARD H #include using namespace std; class Card private: char suit; int rank; public: //Assigns a default value of 2 of Clubs// Card (); Card (char, int); //Returns the Card's suit// char getSuit () const; //Returns the Card's rank as an integer// int getRank () const; friend ostream & operator #include #include #include #include "Deck.h" using namespace std; Deck::Deck () char indSuit; for (unsigned i = 0; i #include #include "Card.h" using namespace std; using namespace std; Card::Card () suit = 'c'; rank = 2; Card: :Card (char cardSuit, int cardRank) cardSuit = tolower (cardSuit); && cardSuit != 'h' && cardSuit != 's') if (cardSuit != 'c' && cardSuit != 'd' cardSuit = 'c'; else suit = cardSuit; cardRank 13 || cardRank = 2; else rank = cardRank; char Card::getSuit () const { return suit; int Card::getRank (0 const { return rank; ostream & operator #include #include #include using namespace std; #include "Deck.h" //#include "Card.h"; //order: Clubs>Diamonds>Hearts>Spades bool hasPair (const vector &); bool compareCards (const Card &one, const Card &two) { //helper if (one.getSuit () two.getSuit ()) == &v, unsigned begin, unsigned mid, unsigned end) i = 0; unsigned unsigned left = 0; unsigned right = 0; begin + 1; //52 int mergedSize = end vector temp (mergedSize); left = begin; //left = 0 = mid + l; //right = 26 right for (i = 0; left &v, unsigned begin, unsigned end) { if (begin end) { return; else if (begin &V) if (v.size () 0) { return; else { mergeSort (v, 0, v.size () 1) : void fillHand (vector &hand, Deck &d, unsigned handSize) { hand.resize (handSize); for (unsigned i = 0; i &v) { if (v.size () 0) { return out; else 1; i++) for (unsigned i = 0; i hand; Deck deck; int handSize; int seed; cout > seed; cout > handSize; cout using namespace std; #include "Card.h" class Deck { private: vector theDeck; vector dealtCards; nublic: Deck deck; int handSize; int seed; cout > seed; cout > handSize; cout using namespace std; #include "Card.h" class Deck private: vector theDeck; vector dealtCards; public: Deck () ; Card dealCard (); void shuffleDeck (); unsigned deckSize () const; }: #endif Write a Card class and a Deck class that stores a deck of these Cards. Then, use the Monte Carlo method to determine the odds of receiving at least one pair in a hand of cards. A pair is any two cards with the same rank. Along with outputting to the terminal the percentage of times a pair is found, your program should also give the user the option to output to a file the contents of each hand and whether it found a pair in that hand. Be sure to reshuffle the deck between each deal (simulation). Your main function should seed the random function with the seed 2222. Given this seed, here is what a sample run of your program will look like if the user chooses NOT to output to a file: Do you want to output all hands to a file?(Yes/No) No Enter number of cards per hand: 5 Enter number of deals (simulations): 10000 Chances of receiving a pair in a hand of 5 cards is: 49.34% Here is what a sample run of your program will look like if the user DOES choose to output to a file: Do you want to output all hands to a file?(Yes/No) Yes Enter name of output file: hands.dat Enter number of cards per hand: 5 Enter number of deals (simulations): 10 Chances of receiving a pair in a hand of 5 cards is: 40% And the file hands.dat in this case would look like this: 10 of Hearts, Ace of Spades, 6 of Clubs, 8 of Spades, Jack of Hearts Found Pair!! Jack of Diamonds, 3 of Diamonds, 2 of Clubs, 2 of Diamonds, 7 of Diamonds Found Pair!! 6 of Clubs, Queen of Hearts, 4 of Spades, 2 of Hearts, 6 of Hearts 7 of Spades, 8 of Clubs, Queen of Hearts, 10 of Spades, 4 of Hearts Found Pair!! 9 of Hearts, King of Clubs, 5 of Spades, 9 of Diamonds, 6 of Diamonds 9 of Spades, 3 of Spades, 4 of Diamonds, Ace of Hearts, Queen of Diamonds 5 of Clubs, 7 of Clubs, 9 of Hearts, Jack of Clubs, 8 of Hearts Jack of Diamonds, 4 of Hearts, 6 of Hearts, Queen of Diamonds, 7 of Diamonds Jack of Spades, 7 of Spades, 10 of Diamonds, 5 of Clubs, 3 of Clubs Found Pair!! 8 of Clubs, Queen of Hearts, 5 of Hearts, Queen of Spades, 10 of Clubs Required Card and Deck interfaces Card.h and Deck.h contain the class declarations for the Card and Deck classes. Use these to create the class definitions in Card.cpp and Deck.cpp. Card.h and Deck.h files cannot be changed. Required global functions (declared and implemented within main.cpp file) /* Passes in a vector Cards and returns true if any 2 Cards have the same rank. Otherwise returns false. * / bool hasPair (const vector &); /* Passes in a vector of Cards and outputs to the stream each Card separated by a comma and a space, with no comma, space, or newline at the end. * / ostream & operator &); Click link for help with overloading the using namespace std; class Card private: char suit; int rank; public: //Assigns a default value of 2 of Clubs// Card (); Card (char, int); //Returns the Card's suit// char getSuit () const; //Returns the Card's rank as an integer// int getRank () const; friend ostream & operator #include #include #include #include "Deck.h" using namespace std; Deck::Deck () char indSuit; for (unsigned i = 0; i #include #include "Card.h" using namespace std; using namespace std; Card::Card () suit = 'c'; rank = 2; Card: :Card (char cardSuit, int cardRank) cardSuit = tolower (cardSuit); && cardSuit != 'h' && cardSuit != 's') if (cardSuit != 'c' && cardSuit != 'd' cardSuit = 'c'; else suit = cardSuit; cardRank 13 || cardRank = 2; else rank = cardRank; char Card::getSuit () const { return suit; int Card::getRank (0 const { return rank; ostream & operator #include #include #include using namespace std; #include "Deck.h" //#include "Card.h"; //order: Clubs>Diamonds>Hearts>Spades bool hasPair (const vector &); bool compareCards (const Card &one, const Card &two) { //helper if (one.getSuit () two.getSuit ()) == &v, unsigned begin, unsigned mid, unsigned end) i = 0; unsigned unsigned left = 0; unsigned right = 0; begin + 1; //52 int mergedSize = end vector temp (mergedSize); left = begin; //left = 0 = mid + l; //right = 26 right for (i = 0; left &v, unsigned begin, unsigned end) { if (begin end) { return; else if (begin &V) if (v.size () 0) { return; else { mergeSort (v, 0, v.size () 1) : void fillHand (vector &hand, Deck &d, unsigned handSize) { hand.resize (handSize); for (unsigned i = 0; i &v) { if (v.size () 0) { return out; else 1; i++) for (unsigned i = 0; i hand; Deck deck; int handSize; int seed; cout > seed; cout > handSize; cout using namespace std; #include "Card.h" class Deck { private: vector theDeck; vector dealtCards; nublic: Deck deck; int handSize; int seed; cout > seed; cout > handSize; cout using namespace std; #include "Card.h" class Deck private: vector theDeck; vector dealtCards; public: Deck () ; Card dealCard (); void shuffleDeck (); unsigned deckSize () const; }: #endif Write a Card class and a Deck class that stores a deck of these Cards. Then, use the Monte Carlo method to determine the odds of receiving at least one pair in a hand of cards. A pair is any two cards with the same rank. Along with outputting to the terminal the percentage of times a pair is found, your program should also give the user the option to output to a file the contents of each hand and whether it found a pair in that hand. Be sure to reshuffle the deck between each deal (simulation). Your main function should seed the random function with the seed 2222. Given this seed, here is what a sample run of your program will look like if the user chooses NOT to output to a file: Do you want to output all hands to a file?(Yes/No) No Enter number of cards per hand: 5 Enter number of deals (simulations): 10000 Chances of receiving a pair in a hand of 5 cards is: 49.34% Here is what a sample run of your program will look like if the user DOES choose to output to a file: Do you want to output all hands to a file?(Yes/No) Yes Enter name of output file: hands.dat Enter number of cards per hand: 5 Enter number of deals (simulations): 10 Chances of receiving a pair in a hand of 5 cards is: 40% And the file hands.dat in this case would look like this: 10 of Hearts, Ace of Spades, 6 of Clubs, 8 of Spades, Jack of Hearts Found Pair!! Jack of Diamonds, 3 of Diamonds, 2 of Clubs, 2 of Diamonds, 7 of Diamonds Found Pair!! 6 of Clubs, Queen of Hearts, 4 of Spades, 2 of Hearts, 6 of Hearts 7 of Spades, 8 of Clubs, Queen of Hearts, 10 of Spades, 4 of Hearts Found Pair!! 9 of Hearts, King of Clubs, 5 of Spades, 9 of Diamonds, 6 of Diamonds 9 of Spades, 3 of Spades, 4 of Diamonds, Ace of Hearts, Queen of Diamonds 5 of Clubs, 7 of Clubs, 9 of Hearts, Jack of Clubs, 8 of Hearts Jack of Diamonds, 4 of Hearts, 6 of Hearts, Queen of Diamonds, 7 of Diamonds Jack of Spades, 7 of Spades, 10 of Diamonds, 5 of Clubs, 3 of Clubs Found Pair!! 8 of Clubs, Queen of Hearts, 5 of Hearts, Queen of Spades, 10 of Clubs Required Card and Deck interfaces Card.h and Deck.h contain the class declarations for the Card and Deck classes. Use these to create the class definitions in Card.cpp and Deck.cpp. Card.h and Deck.h files cannot be changed. Required global functions (declared and implemented within main.cpp file) /* Passes in a vector Cards and returns true if any 2 Cards have the same rank. Otherwise returns false. * / bool hasPair (const vector &); /* Passes in a vector of Cards and outputs to the stream each Card separated by a comma and a space, with no comma, space, or newline at the end. * / ostream & operator &); Click link for help with overloading the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions