Skip to content

Instantly share code, notes, and snippets.

@mattsegura
Created November 21, 2020 05:18
Show Gist options
  • Save mattsegura/fd1b094d9437af4479b953244ee06b6c to your computer and use it in GitHub Desktop.
Save mattsegura/fd1b094d9437af4479b953244ee06b6c to your computer and use it in GitHub Desktop.
primary colors basic program
#include <iostream>
using namespace std ;
int main()
{
string color1,
color2;
cout << endl;
cout << "Enter color 1: ";
cin >> color1;
cout << "Enter color 2: ";
cin >> color2;
cout << endl;
if (color1 == "red" || color1 == "Red")
{
if (color2 == "blue" || color2 == "Blue")
{
cout << color1 << " & ";
cout << color2 << " = purple.\n";
}
else if (color2 == "Yellow" || color2 == "yellow")
{
cout << color1 << " & ";
cout << color2 << " = Orange.\n";
}
}
else if (color1 == "blue" || color2 == "Blue")
{
if (color2 == "red" || color2 == "Red")
{
cout << color1 << " & ";
cout << color2 << " = purple.\n";
}
else if (color2 == "yellow" || color2 == "Yellow")
{
cout << color1 << " & ";
cout << color2 << " = green.\n";
}
}
else if (color1 == "Yellow" || color2 == "yellow")
{
if (color1 == "red" || color2 == "Red")
{
cout << color1 << " & ";
cout << color2 << " = orange.\n";
}
else if (color2 == "blue" || color2 == "Blue")
{
cout << color1 << " & ";
cout << color2 << " = green.\n";
}
}
else
{
cout << "Neither " << color1;
cout << " or " << color2;
cout << " is a prime color. ";
cout << "\nRun the program and try again.\n";
cout << "Remember a primary color is either Red,";
cout << "Blue, or Yellow.\n";
}
cout << endl << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment