Write an application using C visual studio that can be used
Write an application using C# visual studio that can be used to test input values to ensure they fall within an established range. Use an array to keep a count of the number of times each acceptable value was entered. Acceptable values are integers between 0 and 10. Your program should display the total number of valid values inputted as well as the number of invalid entries. Show not only the number of values outside the range, but also the number of non-numeric invalid values entered. For your final display, output a list of distinct valid entries and a count of how many times that entry occurred.
Solution
Code Snipplet :
***********************************************************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
int value;
int invalid = 0;
int[] a = new int[10];
List<int> input = new List<int>();
string line;
while ((line = Console.ReadLine()) != null && line != \"\") {
if (int.TryParse(line, out value) && value > 0 && value < 10)
a[value]++;
else
invalid++;
}
for(int i=1;i<=9;i++)
{
if(a[i]!=0)
Console.WriteLine(\"Valid Number \" + i + \" is entered \" + a[i] + \" times\");
}
Console.WriteLine(\"Number of invalid entries : \" + invalid);
}
}
***********************************************************************************************************************
Special comments
1. A user can enter as many value he/she wants. If a value a is between 0 to 10,where 0 and 10 are exclusive it will count the frequency of the number and if any other integer value is entered or any other non-numeric value is entered it will count it invalid entries.program will display frequency of valid number entered by user and number of invalid entries.
2. A user have to enter the number that he/she want as input and press enter to enter values, if he/she finished with entering as much value requires just press one more enter, program will display the result.
3. Null values are not counted, program will terminate as soon as a null value is entered.
