Answer to Question #333620 in C# for mamako

Question #333620

The first line will contain a message prompt to width of the skyscraper.


The second line will contain a message prompt to height of the skyscraper.


The succeeding lines will contain the skyscraper pattern.



Enter·width·of·skyscraper:·5


Enter·height·of·skyscraper:·10


···*


·*****


·*****


·*****


·*****


·*****


·*****


·*****


·*****


*******

1
Expert's answer
2022-04-25T16:59:17-0400
class Program
{
    static void Main()
    {
        Console.Write("Enter width of skyscraper: ");
        int width = int.Parse(Console.ReadLine());


        Console.Write("Enter height of skyscraper: ");
        int height = int.Parse(Console.ReadLine());


        for (int i = 0; i < height; i++)
        {
            if (i == 0)
            {
                Console.WriteLine(new string(' ', 3) + '*');
                continue;
            }


            if (i == height - 1)
            {
                Console.WriteLine(new string('*', width + 1));
                continue;
            }


            Console.WriteLine(' ' + new string('*', 4));
        }
        
    }
}

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