Below is my current output following my current source code. According to my assignment, after it writes the calculation for when nCount=4
, it should go to a new line like in the picture of the sample program. I'm not sure how to do that kind of formatting, also I need to show just commas. when I use {0:n}
it shows .00 at the end of the number, and I don't want that.
Code:
static void CalculateK(uint nCount)
{
uint kSum = 0;
double kCalc = 0;
double k = 1;
for(int j=1;j<=nCount;j++)
{
kCalc = Convert.ToUInt32(Math.Ceiling((1000) * Math.Pow(Math.E, -k / 20)));
fileOut.Write("{0,2}. {1,3} ", j, kCalc);
kSum += Convert.ToUInt32(kCalc);
k++;
}
fileOut.WriteLine();
fileOut.WriteLine("Sum = {0,5:g}",kSum);
}