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]
3 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]3 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
Give three general reasons for the importance of computer networking.
LiRa [457]
I think the First reason is; it provides the best way of business communication.
Second reason, streamline communication
Third reason cost effective resource sharing :) (hope this helps)
5 0
3 years ago
Which of the following is an individual’s social equals?
ozzi
Its multiple choice what did they say
4 0
4 years ago
What is ODBC? How is it related to SQL/CLI? 10.2. What is JDBC? Is it an example of embedded SQL or of using function calls? 10.
tamaranim1 [39]

Answer:hhhhhhhhh

Explanation:

5 0
3 years ago
16. Your character qualities never change. (3 points)<br> A. True<br> B. False
madam [21]

Answer:

False

Explanation:

Hope this helps!

3 0
3 years ago
Read 2 more answers
How long would you need to work at McDonalds to earn enough money to buy a optiplex 3050, monitor, mouse and keyboard all from d
r-ruslan [8.4K]
So assuming you were buying this piece of trash with the mouse and keyboard it would be around $450. Average pay per hour is $9.10-$10.20 depending on were you live so we will just say $9.50. You'd need to work rougly 47 hours (without taxes) So i'd say 65-75 Hours.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Explain one way that wartime advances in such areas as computers
    10·1 answer
  • Items in the __________ area of a class are accessible to all entities that can "see" the object(s) of that class type
    10·1 answer
  • Micheal has increased the contrast of the given picture. Which feature or menu option of a word processing program did he use? A
    15·1 answer
  • Project 4: Strictly Identical arrays
    7·1 answer
  • Read the excerpt from The Code Book. Other attacks include the use of viruses and Trojan horses. Eve might design a virus that i
    13·1 answer
  • Does anyone know what type of Honda this is and the year of it lol this isn’t school related
    10·1 answer
  • Match the different stages of boot sequence with the order in which they occur.​
    15·2 answers
  • How many times will it tack when you fill 1 - liter of jar with water from the pond and uses 100 - milliliter cup to scoop water
    12·1 answer
  • Which of the following is NOT an example of one of the six primary ways businesses use the Internet?
    10·2 answers
  • 9.3 Code Practice
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!