Write a program in C# that allows any number of values between 0 and 10 to be entered. When the user stops entering the values, display a frequency distribution bar chart. Use asterisks to show the number of times each value was entered. If a given number is not entered, no asterisks should appear on that line. Your application should display error messages if a value outside the acceptable range is entered or if a non-numeric character is entered.
using System;
class AstricPattern{
static void Main(){
Console.WriteLine("-1 for the exist the loop");
int[] frq={0,0,0,0,0,0,0,0,0,0};
while(true){
int value;
string userValue=Console.ReadLine();
bool success = int.TryParse(userValue, out value);
if(success){
if(value==-1){break;}
if(value>=1 && value<=10){
frq[value-1]=frq[value-1]+1;
}
else{
Console.WriteLine("Invalid range");
}
}else{
Console.WriteLine("Invalid input");
}
}
for(int i=0;i<10;i++){
Console.Write((i+1)+" | ");
for(int j=0;j<frq[i];j++){
Console.Write("*");
}Console.WriteLine("");
}
}
}
Get Answers For Free
Most questions answered within 1 hours.