6.2. Write a program using string functions that accepts a coded value of an item and display its equivalent tag price. The base of the key is: 0 1 2 3 4 5 6 7 8 9 ----- X C O M P U T E R S Sample input/output dialogue: Enter coded value: TR.XX Tag price: 68.00
sing 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 coded value: ");
string price = Console.ReadLine();
string coded = price.Replace("X", "0").Replace("C", "1").Replace("O", "2").Replace( "M", "3").Replace("P","4").Replace("U","5").Replace("T","6").Replace("E","7").Replace("R","8").Replace("S","9");
Console.WriteLine("Tag price: " + coded);
}
}
}
Comments
Leave a comment