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
AnnZ [28]
3 years ago
12

Using default arguments, write a function that asks the user for a number and returns that number. the function should accept a

string prompt from the calling code. if the caller does not supply a string prompt, the function should use a generic prompt. next, using function overloading, write a function that achieves the same result.
Computers and Technology
1 answer:
GREYUIT [131]3 years ago
6 0
Here's a solution in C#:<span>

        static int AskNumber(string prompt = "Please enter a number: ")        {            int number;            bool numberOK = false;
            do            {                Console.WriteLine(prompt);                var numberString = Console.ReadLine();                numberOK = int.TryParse(numberString, out number);            } while (!numberOK);
            return number;
        }

If you want to replace the default argument approach with function overloading, you change the function heading to:

        static int AskNumber(string prompt )        {
            // rest stays the same
        }

And add this overload:

        static int AskNumber()        {            return AskNumber("Please enter a number");        }

The compiler will figure out which one to call, so both these will work:

        static void Main(string[] args)        {            AskNumber("Input some digits");            AskNumber();        }</span>
You might be interested in
Mr. Andrews, the lead programmer for the game New Horizons, hires independent testers to check the game for stability and perfor
NikAS [45]
I think “D”, did I help?
5 0
3 years ago
Read 2 more answers
Which windows utility should you use to organize the files on your disk to improve efficiency?
olga55 [171]

<span>Disk Defragmenter, is a windows utility that rearranges the records and unused space on the PC's hard disk so that the operating system accesses data more rapidly and projects run quicker. Disk Defragmenter keeps running on a timetable, yet you can likewise break down and defragment your disk and drives manually.</span>

7 0
3 years ago
Give short answers.
Mkey [24]

Answer:

H) Well it depends how you put it. I'm Doing virtual School for my education. And it is so easy when we have technology out their to provide the help that we need. So I think it has affected education pretty good. You can Also google the answers.

I) Looking up Answers at home

J) Parents can check up on their child's school work and see if they can help them. Also The law is involved in Education.

K) It depend's on how you put it

Explanation:

Short Answers

6 0
3 years ago
What formula would you enter to find the difference between the
nydimaria [60]

Answer:

=B2-C4                        

.

.

.

.

.

.

.

.

.

7 0
3 years ago
Suppose a file system can have three disk allocation strategies, contiguous, linked, and indexed. We have just read the informat
otez555 [7]

Answer:

Since we are using three disk allocation strategies,continuous linked and indexed,therof to process and read allocation strategies we need 99830 disk blocks.

6 0
4 years ago
Other questions:
  • Which of the following best reflects why lighting systems are used when filming on location outdoors? (Select all that apply.)
    10·1 answer
  • A digital footprint is all of the information on-line about a person posted by that person or others, ____________. intentionall
    14·1 answer
  • If your address is 10 B Street, what are the first three bytes in ASCII
    12·1 answer
  • what is the primary way to access applications in windows 8? a. control panel b. start menu c. desktop tiles d. context menu
    7·1 answer
  • Oxygen-18 has an atomic number of 8. How many neutrons are in this isotope?
    7·1 answer
  • How is the cia triad used to evaluate encryption methods?
    6·1 answer
  • "in program arrays12.java a swap method is called. does the swap method exchange parameter values x and y?"
    11·1 answer
  • Complete the function to return the factorial of the parameter using recursion,
    10·2 answers
  • Why can't this app have people ask riddles.
    8·1 answer
  • 3. Rajat wants to assign green colour to a paragraph. Write the code that will help him in completing the task
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!