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
Code a call to the function anotherFunc passing the array myints.
mario62 [17]

Answer:

d)anotherFunc(myints);

Explanation:

When we call a function we just have to pass the names of the arguments to the function.In case of arrays we also just have to pass the name of the array.We don't have to worry about the square brackets.So the function call will be like this.

anotherFunc(myints);

Hence the answer is option d.

4 0
3 years ago
Aubrey is on a Windows machine. She wants to back up her Halloween pictures on an external hard drive. Which of the following ta
Leya [2.2K]

Answer:

no clu3 lol

Explanation:

I'm stupid hahaha

8 0
3 years ago
Why are there so many unit testing tools? Are they efficient? Why or why not?
sineoko [7]

Answer:

 Unit testing is the software testing method in which the individual source code are associate to control data. Unit testing basically test the code to ensure that the data or information meets its design.

The aim of unit testing that each part isolate in the program and display the correct individual parts.

Unit testing tool are efficient as they provide several benefits in the development cycle. The basic efficiency of unit testing tools depend upon its type of testing. Unit testing basically validate the units of source code in the program.

For example: when the loop and function in the program work efficiently.

5 0
3 years ago
Which of these is a major mobile game developer?
Firlakuza [10]
Im thinking Zynga because it has tons of games
7 0
3 years ago
Read 2 more answers
Why was the first computer developed? a.) for personal use, b.) for military purposes, c.) for transportation, d.) for communica
IgorLugansk [536]
B) For Military Purposes but around the 1970s they became widely available to consumers.
5 0
3 years ago
Other questions:
  • Which keyboard feature is a form feed character?
    14·1 answer
  • HELP ME RIGHT NOW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8·1 answer
  • Question 5
    5·1 answer
  • What is the purpose of the .NET Framework Class Library? a. it provides pre-written code that can be used by .NET applications b
    13·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • Which statement does not describe how to save a presentation?
    11·1 answer
  • Find a 95% confidence interval for the mean failure pressure for this type of roof panel.The article "Wind-Uplift Capacity of Re
    7·1 answer
  • Coding 5 - Classes The Item class is defined for you. See the bottom of the file to see how we will run the code. Define a class
    13·1 answer
  • Which of the following is input devices? (a)Scanner (b) Keyboard (c) Both a and b (d) Plotter​
    5·1 answer
  • What is a cloud in the world of computing
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!