Accepts two primary colors from the user, adds them, and displays the output in the new color combination
Write a program that accepts two primary colors from the user, adds them, and displays the output in
the new color combination. If the user enters an incorrect color, the program should display “Colors
you entered are not the correct RGB color combination.”.
using System;
class Mixcolor
{
string col1,col2;
public void Accept()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("This Is Simple Color Mixing Game"+"\n Enter The Color From Given Option Below");
Console.WriteLine("************ You should enter color in lowercase only ************");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Options are ------>\n Red \n Blue \n Green");
Console.WriteLine("Enter the First Color");
col1=Console.ReadLine();
Console.WriteLine("Enter the Second Color");
col2=Console.ReadLine();
}
public void Display()
{
if((col1 == "red" && col2 == "green") || ( col1 == "green" && col2 == "red"))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("yellow");
}
else
if((col1 == "blue" && col2 == "green") || ( col1 == "green" && col2 == "blue"))
{
Console.ForegroundColor = ConsoleColor.Pink;
Console.WriteLine("pink");
}
else
if((col1 == "red" && col2 == "blue ") || ( col1 == "blue" && col2 == "red"))
{
Console.ForegroundColor = ConsoleColor.Purple;
Console.WriteLine("purple");
}
else
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Please enter in correct form");
}
}
public static void Main()
{
Mixcolor mi=new Mixcolor();
mi.Accept();
mi.Display();
Console.ReadKey();
}
}
the new color combination. If the user enters an incorrect color, the program should display “Colors
you entered are not the correct RGB color combination.”.
using System;
class Mixcolor
{
string col1,col2;
public void Accept()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("This Is Simple Color Mixing Game"+"\n Enter The Color From Given Option Below");
Console.WriteLine("************ You should enter color in lowercase only ************");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Options are ------>\n Red \n Blue \n Green");
Console.WriteLine("Enter the First Color");
col1=Console.ReadLine();
Console.WriteLine("Enter the Second Color");
col2=Console.ReadLine();
}
public void Display()
{
if((col1 == "red" && col2 == "green") || ( col1 == "green" && col2 == "red"))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("yellow");
}
else
if((col1 == "blue" && col2 == "green") || ( col1 == "green" && col2 == "blue"))
{
Console.ForegroundColor = ConsoleColor.Pink;
Console.WriteLine("pink");
}
else
if((col1 == "red" && col2 == "blue ") || ( col1 == "blue" && col2 == "red"))
{
Console.ForegroundColor = ConsoleColor.Purple;
Console.WriteLine("purple");
}
else
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Please enter in correct form");
}
}
public static void Main()
{
Mixcolor mi=new Mixcolor();
mi.Accept();
mi.Display();
Console.ReadKey();
}
}
Comments
Post a Comment