0% found this document useful (0 votes)
16 views9 pages

Assignment 7 in Computer Programming

The document provides instructions for an assignment to design a program that displays a color when a letter is inputted. It lists letters and their corresponding colors and provides code samples using if/else statements and a switch statement to output the correct color.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views9 pages

Assignment 7 in Computer Programming

The document provides instructions for an assignment to design a program that displays a color when a letter is inputted. It lists letters and their corresponding colors and provides code samples using if/else statements and a switch statement to output the correct color.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Assignment/Activity No.

Name: Cherry D. Cantuba III


Year and Section: DICT 1-5
Date: June 18, 2021

  Instructions:
Design and develop a simple application program that displays an equivalent color once
an input letter matches its first character.    Use logical OR and relational operator using switch
selection statement. Enhance your form design.  Submit your form design and source code with
correct output.

Letters Colors
        ‘B’ or ‘b’                          blue
        ‘Y’ or ‘y’                          yellow
        ‘R’ or ‘r’                           red
        ‘G’ or ‘g’                          green
      Other letters                    unknown color
If Else Statement:
Source Code:

if (textBox1.Text == "B" || textBox1.Text == "b")

textBox2.Text = "Blue";

else if (textBox1.Text == "Y" || textBox1.Text == "y")

textBox2.Text = "Yellow";

else if (textBox1.Text == "R" || textBox1.Text == "r")

textBox2.Text = "Red";

else if (textBox1.Text == "G" || textBox1.Text == "g")

textBox2.Text = "Green";
}

else

textBox2.Text = "Unknown Color";

Switch Statement:
Source Code:

switch (textBox1)

case 'B' || 'b':

textBox2.Text = "Blue";

break;

case 'Y' || 'y':

textBox2.Text = "Yellow";

break;

case 'R' || 'r':

textBox2.Text = "Red";

break;
}

case 'G' || 'g':

textBox2.Text = "green";

break;

default:

textBox2.Text = "Unknown Color";

You might also like