Program Cs
Program Cs
using LinkedLists;
namespace ProgrammingAssignment2
{
// IMPORTANT: Only add code in the section
// indicated below. The code I've provided
// makes your solution work with the
// automated grader on Coursera
/// <summary>
/// Programming Assignment 2
/// </summary>
class Program
{
// holds the list of input numbers
static UnsortedLinkedList<int> values = new UnsortedLinkedList<int>();
/// <summary>
/// Programming Assignment 2
/// </summary>
/// <param name="args">command-line args</param>
static void Main(string[] args)
{
// loop while there's more input
string input = Console.ReadLine();
while (input[0] != 'q')
{
// extract input values from string
BuildLinkedListFromString(input);
if (count > 0)
{
double mean = (double)sum / count;
Console.WriteLine($"{count} {mean}");
}
else
{
Console.WriteLine("0 0");
}
// and the comment below. You can of
// course add more space between the
// comments as needed
/// <summary>
/// Builds a linked list of input values from provided string
/// </summary>
/// <param name="input">input string</param>
/// <returns>linked list of values</returns>
static void BuildLinkedListFromString(string input)
{
// find first space in string
int spaceIndex = input.IndexOf(' ');
/// <summary>
/// Get a value from the linked list. If the linked
/// list is empty, returns -1
/// </summary>
/// <returns>value or -1 if list is empty</returns>
static int GetValue()
{
// check for empty list
int value;
if (values.Count > 0)
{
// save value at front of list
value = values.Head.Value;