Question: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Numbers { public class NumberList { // Your private List field should go here

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespaceNumbers { public class NumberList { // Your private List field should

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Numbers { public class NumberList { // Your private List field should go here // ...

public void Add(float number) { // ... }

public List Numbers() { // ... }

public float Minimum() { // ... } public float Maximum() { // ... } public float Sum() { // ... } public float Average() { // ... } public int Count() { // ... } public void DeleteBelow(float threshold) { // ... } public void DeleteAbove(float threshold) { // ... } public int CountBelow(float threshold) { // ... } public int CountAbove(float threshold) { // ... } } public class Program { private static string ListToString(List numbers) { string text = ""; for (int i = 0; i 0) text += ", "; text += String.Format("{0}", numbers[i]); } text += ""; return text; } static void Main(string[] args) { NumberList myList = new NumberList(); myList.Add(1); myList.Add(2); myList.Add(3); myList.Add(4); myList.Add(5);

Console.WriteLine("{0} should be 1", myList.Minimum()); Console.WriteLine("{0} should be 5", myList.Maximum()); Console.WriteLine("{0} should be 15", myList.Sum()); Console.WriteLine("{0} should be 3", myList.Average()); Console.WriteLine("{0} should be 5", myList.Count()); Console.WriteLine("{0} should be 2", myList.CountBelow(2.5f)); Console.WriteLine("{0} should be 2", myList.CountAbove(3.5f));

Console.WriteLine("{0} should be 1, 2, 3, 4, 5", ListToString(myList.Numbers())); myList.DeleteBelow(2.5f); Console.WriteLine("{0} should be 3, 4, 5", ListToString(myList.Numbers()));

myList.Add(6); myList.Add(7);

myList.DeleteAbove(4.5f); Console.WriteLine("{0} should be 3, 4", ListToString(myList.Numbers()));

Console.WriteLine(" Press enter to exit."); Console.ReadLine(); } } }

Using C# create a NumberList class. This class will need to keep track of a list of any number of floating-point values and be able to perform operations on these values. Use a private Listfield to keep track of the numbers. For more information on List, see the Week 8 lecture slides and chapter 8 of the textbook. The NumberList class will have the following methods . void Add (float number) This method adds number to the end of the list. If myList is a NumberList containing 1, 23 calling myList.Add (3) will mean that myList now contains 1, 2, 3) . List Numbers () This method returns a list containing all the numbers in the NumberList. As you should be should iust return that List using a private List to keep track of these numbers anyway, this method float Minimum() This method returns the lowest number in the list. . float Maximum() This method returns the highest number in the list. float Sum This method returns the sum of all numbers in the list. If myList Is a Numberlist containing 1, 2, 3) calling myList.Sum) will return6 . float Average() This method returns the average/mean of all numbers in the list. If myList is a NumberList containing 1, 2, 3) calling myList.Sum() will return 2, as the sum of those numbers is 6 and 6 divided by 3 (the number of numbers in the list) is 2 int Count() This method returns the number of numbers in the list. If myList is a NumberList containing 1, 2, 3) calling myList.Count) will return 3 . int DeleteBelow(float threshold) This method removes from the list all numbers that are below threshold. If myList is a NumberList containing {1, 2, 3) calling myList.DeleteBelow (1.5) will remove 1, leaving just {2, 3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!