Professional Documents
Culture Documents
cpp
//List the include files
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
//the struct that is being made is being used outside this source.. Look at the
linked file strudent_record.h
#include"student_record.h"
//How to compute the grade and a way to find out which student you are on
void compute_grade(int j) //index was int to keep track of which student was being
tested
{
//Define a function to input a student record, which consists of all the elements
of the Student_Record struct
//This function should take the subscript of the student array as input.
void input_record(int i)
{
cout << "\t\t\t\t--------------\n\t\t\t\t| |\n\t\t\t\t| Input Info |\n\t\t\t\t| |
\n\t\t\t\t--------------\n\n\n";
cout << "\t\t\t\t Student " << i + 1 << "\n\n";
cout << "Please Enter Student's " << i + 1 << " Last Name:\n";
cin >> students[i].lastName;
cout << "\nPlease Enter Student's " << i + 1<< " First Name:\n";
cin >> students[i].firstName;
cout << "\nPlease Enter Student's " << i + 1<< " Id#:\n";
cin >> students[i].studentId;
cout << "\nPlease Enter Student's " << i + 1<< " Lab Average\n";
cin >> students[i].labAverage;
cout << "\nPlease Enter Studen's " << i + 1<< " Test Average\n";
cin >> students[i].testAverage;
system("cls");
}
void output_record(int i)
{
system("cls");
cout << "\t\t\t\t---------------\n\t\t\t\t| |\n\t\t\t\t| Report Card |\n\t\t\t\t|
|\n\t\t\t\t---------------\n\n\n";
cout << "\t\t\t\t Student " << i << "\n\n";
cout << "\nLast Name: \t" << students[i].lastName;
cout << "\nFirst Name: \t" << students[i].firstName;
cout << "\nStudent ID#: \t" << students[i].studentId;
cout << "\nLab Average: \t" << students[i].labAverage;
cout << "\nTest Average: \t" << students[i].testAverage;
cout << "\nStudents Grade: \t" << students[i].grade;
system("pause") // here is where i have my problem it will pause but only after
you hit it twice and it doesn't do it when it should..
//These are a few things i have tried to do to go around this problem. inputting
what i just call a stepper by using an int of x and then placing in a cin > x; so
that you type a key and press enter to move on.. that hasn't worked.. i have also
tried to force a print before the pause.. that hadn't worked.. there has been many
more things but i just can't think of what else to do to fix my problem..
}
void main(void)
{
int i;
for (i=0; i < 3; i++)
{
input_record(i);
compute_grade(i);
}
}
}
//student_record.h
//List the include files
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
//Define structures
struct Student_Record
{
char lastName[20];
char firstName[20];
char studentId[10];
float labAverage;
float testAverage;
char grade;
};