1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
andreyandreev [35.5K]
3 years ago
6

Write C# program that will read name from keyboard and display it on screen. The program should throw an exception when the leng

th of name is more than 15 character.
Computers and Technology
1 answer:
Hitman42 [59]3 years ago
4 0

Answer:

       static void Main(string[] args)

       {

           try

           {

               Console.Write("Enter your name: ");

               string name = Console.ReadLine();

               if (name.Length > 15)

               {

                   throw new Exception($"Name length {name.Length} is too long, max 15!");

               }

               else

               {

                   Console.WriteLine("Hello " + name);

               }

           }  

           catch(Exception ex)

           {

               Console.WriteLine("Exception occurred: " + ex.Message);

           }

       }

Explanation:

This is one way of doing it. More elaborate is to subclass Exception into NameLengthException and throw that.

You might be interested in
Why did i get blocked
sergejj [24]
Because you asked something innnapropiate
7 0
3 years ago
Read 2 more answers
What is a distraction that you find when photographing animals at the zoo
yaroslaw [1]

D. All of the above.

<u>Reason:</u>

A. Fences can get in the way of a beautiful picture.

B: The animal's enclosure may be hard to get the perfect snap. Like a rock can be in the way of the animal. idk...lol

C. People want to see the animal as much as you do so they may block the way of a picture.

Example from Google..XD


7 0
3 years ago
Question 7 of 10
SpyIntel [72]

Answer:

A

Explanation:

6 0
2 years ago
On Election Day, TV news network Houston News One is trying to project the 2018 Texas election results. They send pollsters to 4
Leni [432]

Answer:

entrance poll

Explanation:

Based on the information provided within the question it seems that the type of poll that the news network is conducting is an entrance poll. This refers to asking question (poll) to people outside of the voting center before they enter to place their vote as opposed to exit poll which is done after the individual has placed their vote.

8 0
3 years ago
Declare an array of int values westboundHollandTunnelTraffic that can store the number of vehicles going westbound through the H
Len [333]

Answer:

Following are the declaration of the array:

int westboundHollandTunnelTraffic [10] [52] [7] [24];  //defining an integer array  that holds days, week, hour, and year value

Explanation:

In the above-given code, an array that's name is " westboundHollandTunnelTraffic " is declared and the type of the storing elements in the array is an integer.

In this array, it first stores the year's value, and in second, it stores week values, in third, it stores day value, and the last it stores hours value.    

6 0
4 years ago
Other questions:
  • Which is the first step in visual character development?
    11·2 answers
  • ¿como influye la tecnologia en su vida cotidiana?
    7·1 answer
  • How do solar system and galaxies differ?
    9·1 answer
  • What does it mean to empty the cache?
    6·1 answer
  • A major concern about ESP claims is that proponents explain both the positive and negative findings. By explaining the negative
    14·1 answer
  • A(n) ___________ operating system provides process and memory management services that allow two or more tasks, jobs, or program
    6·1 answer
  • PLEASE HURRY!!<br> Look at the image below!
    13·1 answer
  • If you have limited means, you...?
    9·1 answer
  • A friend a just opened his own barber shop and has asked you to develop a program to track the type of service the customer is r
    8·1 answer
  • In response to an alert regarding a possible security incident, you are analyzing the logs for a web application. In the process
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!