programming project, revise
- From: "\"The Master\"" <jordanvdf@xxxxxxxxx>
- Date: Wed, 5 Nov 2008 07:09:29 -0800 (PST)
Hey, I am working on a project where a program has to read in a
collection of exam scores ranging in value from 0 – 100. The program
should count and print the number of outstanding scores (90-100) the
number of satisfactory scores (60-89) the number of unsatisfactory
scores (0-59) and the number of invalid scores (less than 0 or
greater
than 100).
The program should print output starting at the top of the page with
your name followed by some column headings to identify the output.
example:
Outstanding Satisfactory Unsatisfactory Invalid
90 89
44 212
98 76
35 -8
This is what I have for my source code so far. But I am having
problems getting the data to display correctly.
#include <stdio.h>
int main(void)
{
// Programmer Jordan Van der Flier
// November 2008
// COP 2000 Intro to Programming
// Categorizes a list of grades, calculates, max, min, and avg
FILE *in; // delcares a file type, assigns name 'in'
int grade;
int max, min, avg;
int count = 0;
int outstanding, satisfactory, unsatisfactory, invalid;
// associates 'in' with file location
in = fopen("i:\\numbers.dat", "r"); // file location,
"r" means read
fscanf(in, "%d", &grade); // scans from
external source
printf(" Outstanding Satisfactory Unsatisfactory
Invalid ");
printf("\n Grade Grade
Grade Grade");
while(! feof(in)){ // while 'not' at
End Of File
if(90 <= grade && grade <= 100){ // grades 90-100
outstanding = grade;
printf("\n %d", outstanding);
}
else if(60 <= grade && grade <= 89){ // grades 60-89
satisfactory = grade;
printf("\n %d", satisfactory);
}
else if(0 <= grade && grade <= 59){ // grades 0-59
unsatisfactory = grade;
printf("\n %d", unsatisfactory);
}
else if(0 > grade || grade > 100){ // grades less than 0 or
greater than 100
invalid = grade;
printf("\n %d", invalid);
}
else {}
fscanf(in, "%d", &grade);
}
fclose(in);
return(0);
}
.
- Follow-Ups:
- Re: programming project, revise
- From: William Pursell
- Re: programming project, revise
- From: Trent Josephsen
- Re: programming project, revise
- From: CBFalconer
- Re: programming project, revise
- Prev by Date: Re: ShareWare vs Evaluation
- Next by Date: Pointer to "base" type - what does the Standard say about this?
- Previous by thread: Re: right padding
- Next by thread: Re: programming project, revise
- Index(es):
Relevant Pages
|