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
How is a secure HTTP (HTTPS) different from a non-secured HTTP?
GuDViN [60]

Answer:

the second last option

Explanation:

secure HTTP is armed with passwords to ensure that only authorised users gain entry.

the data is encrypted during transmission

6 0
2 years ago
You need to fax a portion of a map from a large hard-cover atlas to a client from an internal fax-modem. To fax the map, the bes
Kay [80]
The fax modem is used to send and receive fax messages by only having phone line (fax machine is not required). The scanned documents should be saved as digital file (image or PDF format) in order to be sent. So, in order to send a portion of a map you should first convert the map into digital file and than simply send it through the fax modem. The best way to convert it to a digital file is to use an optical character recognition (OCR). 
6 0
3 years ago
Using reliable internet sources, identify three ways we use analog and digital signals in our everyday lives.
Montano1993 [528]
Clocks maybe is the answer. I really don’t know
7 0
3 years ago
What does foreshortening affect
AlexFokin [52]
Foreshortening is the visual effect or optical illusion that causes an object or distance to appear shorter than it actually is because it is angled toward the viewer. Additionally, an object is often not scaled evenly: a circle often appears as an ellipse and a square can appear as a trapezoid.
3 0
3 years ago
Python
xeze [42]

Answer:

Following are the function to the Python Programming Language.

#define a function to read or crates the list

def GetUserValues():

 my_list=[]

 n=int(input("Enter range: "))

 for i in range(n):

   my_list.append(int(input(" :")))

 return my_list

#define a function to check the elements of the list

def IsListEven(mylist):

 #set the for loop

 for i in range(len(mylist)):

   #set if condition to check odd number

   if mylist[i]%2 !=0:

     #if condition is true retun false

     return False

 #otherwise return true

 return True

#define a function to check the elements of the list

def IsListOdd(mylist):

 #set the for loop

 for i in range(len(mylist)):

   #set if condition to check even number

   if mylist[i]%2==0:

     #if condition is true retun false

     return False

 #otherwise return true

 return True

#set variable to store list

l=GetUserValues()

#set if condition to check the function is true

if IsListOdd(l)==True:

 #then, print the message

 print("all odd")

#set elif condition to check the function is true

elif IsListEven(l)==True:

 #then, print the message

 print("all Even")

else:

 #otherwise print message.

 print("not even or odd")

<u>Output:</u>

Enter range: 5

:2

:4

:6

:8

:10

all Even

Explanation:

Here, we define a function "GetUserValues()" and inside the function.

  • Set the list data type variable "my_list" then, get input from the user in the variable "n".
  • Set the for loop which starts from 0 and end at the variable "n" then, get input from the user and appends inputs in the variable "my_list".
  • Then, we return list and close the function.

Then, we set a function "IsListEven()" and pass an argument "mylist" to check the elements is even or not, if the list elements is even then, return true otherwise, return false.

Then, we set a function "IsListOdd()" and pass an argument "mylist" to check the elements is odd or not, if the list elements is odd then, return true otherwise, return false.

Finally, we call and store the function in the variable "l" then, set conditions to check the list is even print "all even", if the is odd "all odd" otherwise, print "not even or odd".

3 0
4 years ago
Other questions:
  • A software program that enables users to find and display information stored as html pages on the internet is a(n) ____.
    5·1 answer
  • The countryside presents
    11·1 answer
  • When preparing a document flowchart, the names of organizational departments or job functions should appear in theA) column head
    6·1 answer
  • How many categories of bitmap images are there?
    8·1 answer
  • Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
    11·1 answer
  • How is kerning used in Word?
    7·2 answers
  • Controlling access of information on the internet
    15·1 answer
  • In this exercise you will debug the code which has been provided in the starter file. The code is intended to do the following:
    8·1 answer
  • What technology would a bank's website use a scramble information as it is transmitted over the Internet
    7·1 answer
  • Differenciate between foreign key and primary key in database.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!