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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter Price: ");
string price = Console.ReadLine();
string coded = price.Replace("0", "X").Replace("1", "C").Replace("2", "O").Replace("3", "M").Replace("4", "P").Replace("5", "U").Replace("6", "T").Replace("7", "E").Replace("8", "R").Replace("9", "S");
Console.WriteLine("Coded Value: " + coded);
}
}
}
Comments
Leave a comment