Answer to Question #297618 in C# for JONBONJI

Question #297618

Write an algorithm that displays an equivalent color once an input letter matches its first character.



For example b for Blue, r for Red, and so on. Here are the given criteria: (The letters as an input data and the color as output information).



Letters Color



‘B’ or ‘b’ Blue



‘R’ or ‘r’ Red



‘G’ or ‘g’ Green



‘Y’ or ‘y’ Yellow



Other letters “Unknown Color”




















1
Expert's answer
2022-02-14T13:24:51-0500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Console.Write("Enter first character: ");
            string c = Console.ReadLine().ToLower();

            switch (c)
            {
                case "b": Console.WriteLine("Blue");
                    break;
                case "r":
                    Console.WriteLine("Red");
                    break;
                case "g":
                    Console.WriteLine("Green");
                    break;
                case "y":
                    Console.WriteLine("Yellow");
                    break;
                default:
                    Console.WriteLine("Unknown Color");
                    break;
            }


                Console.ReadKey();
        }
    }

   
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS