0

the output should be:
Triangle Drawer

Enter the size of the triangle: 0
The size is out of range.
Enter the size of the triangle: 11
The size is out of range.
Enter the size of the triangle: cats
An invalid value was entered.
Enter the size of the triangle: 10

TTTTTTTTTT
TTTTTTTTT
TTTTTTTT
TTTTTTT
TTTTTT
TTTTT
TTTT
TTT
TT
T

Press any key to exit:

Console.Title = "Triangle Drawer";

            Console.Write("{0, 40}", "Triangle Drawer");

            int iSize = 0;
            bool bError;

            do
            {
                try
                {
                    bError = false;
                    Console.Write("\nEnter the size of the triangle: ");
                    iSize = int.Parse(Console.ReadLine());

                    if ((iSize <= 1) || (iSize >= 11))
                    {
                        Console.Write("\nThe size is out of range.");
                        bError = true;
                    }
                }
                catch (FormatException)
                {
                    Console.Write("\nAn invalid value was entered.");
                    bError = true;
                }
                finally
                {
                    Console.WriteLine("");
                    bError = true;
                }
                for (int iRow = 0; iRow < iSize; iRow++)
                {
                    for (int iColumn = 0; iColumn < iSize; iColumn++)
                        Console.Write("T");
                    Console.WriteLine();
                }
            }
            while (bError);

            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();

mine is showing like this
TTTT
TTTT
TTTT
TTTT
TTTT

3
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by minitech
0

Your second for loop's conditional part should be iColumn <= iSize - iRow .

Edited by minitech: n/a

2

Line32 should be for (int iRow = iSize; iRow > 0; iRow--) { Line 34 should be for (int iColumn = 0; iColumn < iRow; iColumn++) {

0

how come if press 1 or 11 for iSize

its showing:
The size is out of range.
"T"

1

Instead of setting bError = true; , just take out bError entirely and use continue; instead where bError = true; used to be. Replace the while(bError) with while(true) .

Edited by minitech: n/a

0

i have another question.
just to make sure
am i using double for loop???

0

No, why would you draw a triangle with base 5.2? You can't draw part of a T. int fits everything between 2 and 10 (and much more) so it's all you need.

0

im just following what is the instruction said...
can u tell me how to use double for loop?

Edited by JudeV: n/a

0

Yes, you're using 2 for loops, if that's what the instructions mean.

Edited by minitech: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.