If anyone could please help. I have to create a (if/then and a loop) program where the user inputs three numbers from 1-13 and it's supposed to identify what playing cards the user has (4 required examples below). No playing card suits are required.
EXAMPLES:
All cards are equal.
Sample output for 4 4 4: You have three fours.
Three cards form a straight.
Sample output for 8 6 7: You have a straight ending in eight.
Two cards are equal.
Sample output for 6 6 3: You have a pair of sixes.
Name of the highest card.
Sample output for 11 1 8: You have a jack
This is all I have to start with for now. Having some trouble going on from here. Any suggestions? Thanks!:
// I have to create a (if/then and a loop) program where the user inputs
// three numbers from 1-13 and it's supposed to identify what playing cards
// the user has (4 required examples below). No playing card suits are required.
// EXAMPLES:
// All cards are equal.
// Sample output for 4 4 4: You have three fours.
// Three cards form a straight.
// Sample output for 8 6 7: You have a straight ending in eight.
// Two cards are equal.
// Sample output for 6 6 3: You have a pair of sixes.?
// Name of the highest card.
// Sample output for 11 1 8: You have a jack
#include <iostream>
#include <string>
constexprint PLAYING_CARD_MIN = 1;
constexprint PLAYING_CARD_MAX = 13;
// one, two are supposed to be sorted in descending order
std::string getCombination(int three, int two, int one);
int main()
{
// 1.1
std::cout << "Please input three playing card numbers ranging from "
<< PLAYING_CARD_MIN << " to " << PLAYING_CARD_MAX
<< ", separated by spaces: ";
int card1 {}, card2 {}, card3 {};
std::cin >> card1 >> card2 >> card3;
std::cin.ignore(999, '\n');
// 1.2 Sort Cards
bool again = true;
while(again) {
again = false;
if(card1 > card2) {
int temp = card1;
card1 = card2;
card2 = temp;
again = true;
}
if(card2 > card3) {
int temp = card2;
card2 = card3;
card3 = temp;
again = true;
}
}
std::cout << card3 << ' ' << card2 << ' ' << card1 << ' '
<< getCombination(card3, card2, card1) << '\n';
return 0;
}
std::string getCombination(int three, int two, int one)
{
std::string comb = "you have ";
// check for tris:
if(three == two && two == one) {
comb += "three " + std::to_string(one);
return comb;
}
// check for a straight
if( /* ... */ ) {
// ...
return comb;
}
// check for a couple
if( /* ... */ ) {
// ...
return comb;
}
// check if the highest card is higher then 10
if( /* ... */ ) {
// ...
return comb;
}
// ...
return comb + "nothing useful";
}