1
Answer

C# Programming assignment

Administrator

Administrator

22y
1.6k
1
Hi Guys, I have to create a notepad web control for a callaboratory project in one of my college courses. I was wondering if someone would be kind enough to talk to me through AIM or email to help me start this project. I'm pretty new with C# and .NET. The notepad can be very basic, no dropdown menus or anything. All I need is a text field for the user to type(Obviously), and buttons along the top for save, undo, copy, paste, and cut. I'd appreciate any help you can offer...Thank you.
Answers (1)
0
Vulpes

Vulpes

NA 98.3k 1.5m 10y
Accepted
1
Niranjan Poddar

Niranjan Poddar

NA 308 39.7k 10y
try this........

 public static string ConvertNumbertoWords ( int number )
    {
        if ( number == 0 )
            return "Zero";
        if ( number < 0 )
            return "minus" + ConvertNumbertoWords ( Math.Abs ( number ) );

        string words = "";
        if ( ( number / 1000000 ) > 0 )
        {
            words += ConvertNumbertoWords ( number / 1000000 ) + " MILLION ";
            number %= 1000000;
        }
        if ( ( number / 1000 ) > 0 )
        {
            words += ConvertNumbertoWords ( number / 1000 ) + " THOUSAND ";
            number %= 1000;
        }
        if ( ( number / 100 ) > 0 )
        {
            words += ConvertNumbertoWords ( number / 100 ) + " HUNDRED ";
            number %= 100;
        }
        if ( number > 0 )
        {
            if ( words != "" )
                words += "AND ";
            var unitsMap = new[] { "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN",
                "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN" };
            var tensMap = new[] { "ZERO", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY" };

            if ( number < 20 )
                words += unitsMap[number];
            else
            {
                words += tensMap[number / 10];
                if ( ( number % 10 ) > 0 )
                    words += " " + unitsMap[number % 10];
            }
        }
        return words;

    }
    protected void btnConvert_Click1 ( object sender, EventArgs e )
    {
        string word = ConvertNumbertoWords ( Convert.ToInt32 ( txtFig.Text ) );
        lblWord.Text = word;
    }