Answer to Question #325772 in C# for chi

Question #325772

6.1.

Write a program using standard string functions that accepts a price of an item and display its coded value.


The base of the key is: X C O M P U T E R S 1 2 3 4 5 6 7 8 9


Sample input/output dialogue: Enter price: 489.50


Coded value: PRS.UX


1
Expert's answer
2022-04-09T17:55:19-0400
    internal class Program
    {
        static void Main()
        {
            Console.Write("Enter price: ");
            string price = Console.ReadLine();
            string code = "";
            for (int i = 0; i < price.Length ; i++)
            {
                if (price[i] == '0')
                    code += "X";
                else if (price[i] == '1')
                    code += "C";
                else if (price[i] == '2')
                    code += "O";
                else if (price[i] == '3')
                    code += "M";
                else if (price[i] == '4')
                    code += "P";
                else if (price[i] == '5')
                    code += "U";
                else if (price[i] == '6')
                    code += "T";
                else if (price[i] == '7')
                    code += "E"; 
                else if (price[i] == '8')
                    code += "R";
                else if (price[i] == '9')
                    code += "S";
                else if (price[i] == '.')
                    code += ".";
            }
            Console.WriteLine($"Coded value: {code}");
            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