// 02192008.cpp, P H Anderson, Feb 18, '08

#include <stdio.h>
#include <stdlib.h>

FILE *fr;

int main()
{
    int num, dice;
    float grade;
    
    int count[13] = {0}, n;
    
    fr = fopen("c:\\grades.txt", "rt");
    if (fr == NULL)
    {
        printf("Error opening file.\n");
        while (getchar() != 'x')
        {
        }
        exit(0);
    }
    // else
    while(1)
    {
        num = fscanf(fr, "%f", &grade);
        if (num != 1)
        {
            printf("No more data\n");
            fclose(fr);
            break;
        }
        else
        {
            printf("%.2f\n", grade);
        }
    }
    
    while(getchar() != 'x')
    {
    }
    
    for (n=0; n<1000; n++)
    {
        dice = rand()%6 + 1 + rand()%6 + 1;
        ++count[dice];
    }
    
    for (n=1; n<=12; n++)
    {
        printf("%i\t%i\n", n, count[n]);
    }
    
    while(getchar() != 'x')
    {
    }  
}