I need to output the results from a .dat file then have it read in data and assign a new * for every 2% each record equals.
It is meant to appear as this:
0 10 20 30 40 50 60 70 80 90 100
| | | | | | | | | | |
*****************************************************************
**** A
************** B
********************* C
****** D
E
**** F
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Grades_10181838_Software_Development
{
class Grades
{
public static void Main(string[] args)
{
int Agrade = 0;
int Bgrade = 0;
int Cgrade = 0;
int Dgrade = 0;
int Egrade = 0;
int Fgrade = 0;
TextReader reader = new StreamReader("grades.dat");
string records;
records = reader.ReadLine();
while (records != null)
{
try
{
records = reader.ReadLine();
if (records == "A")
Agrade++; //
if (records == "B")
Bgrade++; //increment grade by 1
if (records == "C")
Cgrade++; //increment grade by 1
if (records == "D")
Dgrade++; //increment grade by 1
if (records == "E")
Egrade++; //increment grade by 1
if (records == "F")
Fgrade++;//increment grade by 1
}
catch (Exception)
{
Console.WriteLine("Error Check .dat File");
}
{
{
Console.WriteLine("0\t10\t20\t30\t40\t50\t60\t70\t80\t90\t100");
Console.WriteLine("|\t|\t|\t|\t|\t|\t|\t|\t|\t|\t|");
Console.WriteLine("********************************************************************************");
int resultA = Agrade * 100 / 50;
int resultB = Bgrade * 100 / 50;
int resultC = Cgrade * 100 / 50;
int resultD = Dgrade * 100 / 50;
int resultE = Egrade * 100 / 50;
int resultF = Fgrade * 100 / 50;
int counter = 0;
while (counter != resultA)
{
Console.WriteLine("*");
counter ++;
break;
}
while (counter != resultB)
{
Console.WriteLine("*");
counter++;
}
while (counter != resultC)
{
Console.WriteLine("*");
counter++;
}
while (counter != resultD)
{
Console.WriteLine("*");
counter++;
}
while (counter != resultE)
{
Console.WriteLine("*");
counter++;
}
while (counter != resultF)
{
Console.WriteLine("*");
counter++;
}
Console.ReadLine();
}
}
}
}
}
}