Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODED IN C++ -Prompt the user to enter five integer numbers (Range: one through six inclusive on both ends) -Each time the user enters a

CODED IN C++

-Prompt the user to enter five integer numbers (Range: one through six inclusive on both ends)

-Each time the user enters a valid number, place it into a multiset of integers -Create and use a set of integers with your data to determine if it is a Yahtzee! (5 of a kind)

-Create this set and also create a map of integer keys and integer values to determine the rest of the possible results:

-Display to the user the best of the six possible results that they have achieved with the result of their turn 5 of a kind (Ordered best to worst) 4 of a kind Full house (3 of a kind plus a pair) 3 of a kind, Large straight, Small straight, or Nothing

I HAVE CODE ALREADY BUT NEED HELP FINISHING LAST 2 STEPS!

#include

#include

#include

bool isYahtzee(std::multiset& yahtzeSet)

{

for (auto iter = yahtzeSet.begin(); iter != yahtzeSet.end(); ++iter)

{

if (yahtzeSet.find(*iter) == yahtzeSet.end())

{

return false;

}

}

return true;

}

void results(std::map& yatze)

{

std::map::iterator it;

std::pair result = *yatze.begin();

for(it = yatze.begin(); it != yatze.end(); it++)

{

}

}

int main()

{

int num1;

int num2;

int num3;

int num4;

int num5;

std::multiset yahtze;

std::cout << "Enter a number between 1 and 6: ";

std::cin >> num1;

yahtze.insert(num1);

std::cout << "Enter a number between 1 and 6: ";

std::cin >> num2;

yahtze.insert(num2);

std::cout << "Enter a number between 1 and 6: ";

std::cin >> num3;

yahtze.insert(num3);

std::cout << "Enter a number between 1 and 6: ";

std::cin >> num4;

yahtze.insert(num4);

std::cout << "Enter a number between 1 and 6: ";

std::cin >> num5;

yahtze.insert(num5);

std::cout << std::endl;

isYahtzee(yahtze);

if (!isYahtzee)

std::cout << "YAHTZEE!!!! " << std::endl;

std::map combinations{ std::make_pair(1,num1),

std::make_pair(2,num2),

std::make_pair(3,num3),

std::make_pair(4,num4),

std::make_pair(5,num5)};

//results(combinations);

system("Pause");

return 0;

}

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

Students also viewed these Databases questions