CSCI 1170: Open Lab Assignment #5
Program due: Thursday, Oct 29, 2009 at midnight as the day turns to Friday Oct 30, 2009.

Professor: c8296800
code: ola5
Purpose of this assignment: The purpose of this assignment is to understand the while loop programming construct. This assignment will let you

1. practice designing an algorithm (solution)
2. practice iteration and selection

Note: do NOT use an array or function in this assignment
Problem Statement : Write a program to help the fifth grade teacher, Mrs. Johnson. She needs a program that computes student averages as well as the final average of her class. Class scores are stored in a file. The first line of the file contains the number of test scores per students and the rest are student records. Each record contains a student name and the test scores ranging in value from 0 to 100.

Problem Requirements:

1. Read the number of test scores and student records until the end of file is reached.
2. Compute the average grade for each student
3. Print the letter grade for each student
4. print A if (90 to 100)
5. print B if (80 below 90)
6. print C if (70 below 80)
7. print D if (60 below 70)
8. print F if (below 60)
9. compute and display the average for the class (i.e., the average of the student averages)
10. assume all the scores are valid (between 0 and 100 inclusive)
11. display the output in a table format with a heading
12. display the number of test scores per student and the number of students in the class.

For example, if the input file ola5.2 contains :

``````3
Tracy 80 91 67
Dana 0 66 44
Scott 50 41 64
Jamie 82 90 87
Jennifer 95 100 90
William 67 77 62
Wendy 90 96 84
Heather 80 91 86
John 100 100 99
``````

Your output may look like :

``````Please enter the file name that contains the student records: ola5.2
there are 3 scores per student

Student name    test1 test2 test3  final score  grade

-------------------------------------------------------

Tracy             80    91    67        79.33     C

Dana               0    66    44        36.67     F

Scott             50    41    64        51.67     F

Jamie             82    90    87        86.33     B

Jennifer          95   100    90        95.00     A

William           67    77    62        68.67     D

Wendy             90    96    84        90.00     A

Heather           80    91    86        85.67     B

John             100   100    99        99.67     A

The class average is 77.00
There are 9 students.
``````

As another example, if the input file ola5.2b contains :

``````4
Tracy 80 91 67 78
Scott 50 41 64 72
Jamie 82 90 87 91
Jennifer 95 100 90 98
William 67 77 62 71
Wendy 90 96 84 95
Heather 80 91 86 84
John 100 100 99 100
``````

Your output may look like :

``````Please enter the file name that contains the student records: ola5.2b
there are 4 scores per student

Student name    test1 test2 test3 test4  final score  grade

-------------------------------------------------------------

Tracy             80    91    67    78        79.00     C

Scott             50    41    64    72        56.75     F

Jamie             82    90    87    91        87.50     B

Jennifer          95   100    90    98        95.75     A

William           67    77    62    71        69.25     D

Wendy             90    96    84    95        91.25     A

Heather           80    91    86    84        85.25     B

John             100   100    99   100        99.75     A

The class average is 83.06
There are 8 students.
``````

this is what i have gotten so far. ( incomplete at some points)

``````#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

int main()
{
char a;
int count;
int dashCount;
int scores;
float num1, num2, num3, num4;
float average;
string fileName;
string name;
ifstream myin;
float number;
cout << "Please enter the file name that contains the student records: ";
cin >> fileName;
myin.open(fileName.c_str());

myin.get(a);
cout << "there are " << a << " scores per student\n";
cout << endl;
cout << "Student name ";

int b;
b = static_cast(a);
count = 1;
while (count <= a)
{
cout << "test" << count << "  ";
count++;
}

cout << "final score  grade\n";
cout << endl;

dashCount = count * 8 + 31;
count=1;

while (count<= dashCount)
{

cout <<"-";
count++;
}

cout << endl;
cout << endl;

while (myin)
{
myin >> name;
cout << name ;
myin >> num1 >> num2 >> num3;
cout << "     " << fixed << setprecision(0)<< num1  << "  "<< num2 << "   "<< num3 ;
average = (num1 + num2 + num3)/3;

cout << " " << fixed << setprecision(2)<< average ;
if ( average >= 90)
cout << "     A";
else if( average > 80)
cout << "     B";
else if( average > 70)
cout << "     C";
else if( average > 60)
cout << "     D";
else
cout << "     F";

cout << endl;
}

cout << "The class average is " << endl;
cout << "There are " << " students\n";

myin.close();
return 0;
}
``````

i am not allowed to use anything higher than and including fuctions.
i am a noob and have no idea how to solve my problem.
please help me out!!!
and please make it very very simple, not using anything above beginner level.
thanks!!!