Muhammad Nadeem

Muhammad Nadeem

  • NA
  • 548
  • 66.6k

How to make more length

May 6 2016 12:50 AM
I want to make more length of this code minimum 100. please guide me how to increase my code length because I want more understanding. Thanks
 
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
HeavyDeciCount(9872, 9884);
}
public static void HeavyDeciCount(int x, int y)
{
var totalHeavyCount = 0;
for (int i = x; i <= y; i++)
{
var avg = i.ToString() // convert an integer to string - "9872"
.Select(o => Convert.ToInt32(o.ToString())) // convert each string character to integer - 9, 8, 7, 2
.ToArray() // create array of all integers - { 9, 8, 7, 2 }
.Average(); // calc the average of the array numbers
var isHeavy = false;
if (avg > 7)
{
isHeavy = true;
totalHeavyCount++;
}
Console.WriteLine(i + " " + avg + " " + (isHeavy ? "Yes" : "No"));
}
Console.WriteLine("Total heavy count: " + totalHeavyCount);
Console.Read();
}
}
}
 

Answers (1)