Hi I'm still fairly new to programming and I am in the middle of a home work question Though I bricked at this point. I was able to write out the base of the program, however it's functioning the way I want it to. What it needs to do is display the result color of entering two primaries and display an error if anything else has been entered, however it just jumps straight to the error.
5. Color Mixer
The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:
● When you mix red and blue, you get purple.
● When you mix red and yellow, you get orange.
● When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.
What I have tried:
Module Module1
Sub Main()
Dim Red As String
Dim Blue As String
Dim Yellow As String
Dim Color1 As String
Dim Color2 As String
Console.WriteLine("Input 2 colors Choices one at a time from Red, Blue, or Yellow.")
Color1 = Console.ReadLine
Color2 = Console.ReadLine
If Color1 = Red And Color2 = Blue Then
Console.WriteLine("Purple")
Else If Color1 = Red And Color2 = Yellow Then
Console.WriteLine("Orange")
ElseIf Color1 = Yellow And Color2 = Blue Then
Console.WriteLine("Green")
Else
Console.WriteLine("Error: Invalid input")
End If
Console.WriteLine("Press Enter to quit.")
Console.ReadKey(ConsoleKey.Enter)
End Sub
End Module
Side notes:
(*)I've also tried not making the primary colors variables, however it caused a syntax error.
(*)The language we use in class is VB.