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
alexdok [17]
2 years ago
11

Write a program that include a method that returns the sum of all the elements of a Linked List of Integers. Allow the user to e

nter the integers to be added to your Linked List from the console (max of 10 integers). Test your program and display your integers and the sum results.
Computers and Technology
1 answer:
Illusion [34]2 years ago
8 0

Answer:

static void Main(string[] args)

       {

           //declare a blank linked list

           LinkedList<int> numList = new LinkedList<int>();

           Console.WriteLine("Enter the Numbers");

           //check if the size of the linkedlist is 10

           while(numList.Count < 10)

           {

               //read the input supplied by the user

               string val = Console.ReadLine();

               //check if the input is integer

               if(int.TryParse(val, out _) == false)

               {

                   //if not integer, display error message and prompt for new number

                   Console.WriteLine("Invalid number");

                   continue;

               }

               //add the inputted number to the linkedlist

               numList.AddLast(int.Parse(val));

               

           }

           //call the method for linkedlist sum and display it

           Console.WriteLine(SumLinkedList(numList));

           Console.Read();

       }

       //method for linkedlist summation

       private static int SumLinkedList(LinkedList<int> val)

       {

           //declare sum as zero

           int sum = 0;

           //loop through the linkedlist to display the num and sum all numbers

           foreach(int item in val)

           {

               Console.Write(item + " ");

               sum += item;

           }

           return sum;

       }

   }

Explanation:

program written with c#

You might be interested in
Animation and transition effects will distract your audience when using a slide show presentation aid. True or false ?
lions [1.4K]
I suspect the answer they're looking for is false. However, as an experienced professional in learning and development, I can tell you that when done right these effects can enhance a presentation.
4 0
3 years ago
Read 2 more answers
John typed 545 words in 35 minutes, what is his typing speed
Katarina [22]

Answer: 545 words per 35 mins

Explanation:

4 0
2 years ago
Read 2 more answers
Which of the following are examples of IT
Advocard [28]

Answer:

Computer hardware engineer

Systems analyst

Database administrator

7 0
3 years ago
Why does it say error on that last line of code
wel

Answer:

i have no clue

Explanation:

8 0
3 years ago
Read 2 more answers
WILL MARK BRAINLIEST.....
slamgirl [31]

Answer:

Variables. A variable is a way of naming and storing a value for later use by the program, ... its type, and optionally, setting an initial value (initializing the variable). ... byte x; x = 0; x = x - 1; // x now contains 255 - rolls over in neg. direction

Explanation:

7 0
3 years ago
Other questions:
  • After you enter the details for the first selected recipient in the New Address List dialog box, click _______ to add another re
    11·2 answers
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • The United States is the only country in the world in which organs and tissue transplants are performed. True or False?
    8·1 answer
  • What is the description of a computer ram?
    7·1 answer
  • 0.005098 megaliters to liters. record your answer in whole liters
    7·1 answer
  • Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if
    9·1 answer
  • Which C99 function can be used to convert a string to a double?
    15·1 answer
  • What best describes "broadband access"?
    13·1 answer
  • Which type of evaluation requires that the program be fully implemented before the evaluation can begin
    9·1 answer
  • Different Betweens ServerPc And Desktop Pc ~
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!