Click here to Skip to main content
15,910,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: LPCSTR and LPCWSTR Pin
George_George20-Aug-07 17:36
George_George20-Aug-07 17:36 
GeneralRe: LPCSTR and LPCWSTR Pin
Iain Clarke, Warrior Programmer21-Aug-07 0:02
Iain Clarke, Warrior Programmer21-Aug-07 0:02 
GeneralRe: LPCSTR and LPCWSTR Pin
George_George21-Aug-07 1:24
George_George21-Aug-07 1:24 
GeneralRe: LPCSTR and LPCWSTR Pin
Iain Clarke, Warrior Programmer21-Aug-07 3:29
Iain Clarke, Warrior Programmer21-Aug-07 3:29 
GeneralRe: LPCSTR and LPCWSTR Pin
George_George21-Aug-07 5:28
George_George21-Aug-07 5:28 
QuestionIDispatch to class object Pin
Monark20-Aug-07 4:54
Monark20-Aug-07 4:54 
AnswerRe: IDispatch to class object Pin
Mark Salsbery20-Aug-07 8:05
Mark Salsbery20-Aug-07 8:05 
QuestionTrouble with vectors. Newbie needs help! Pin
Flipflopninja20-Aug-07 4:49
Flipflopninja20-Aug-07 4:49 
I am having trouble gettting this program to compile and I am not sure why. It keeps telling me that every time I try to declare a new instance of student (example; student st) it says I am missing parameters for it. Maybe someone can offer a little assistance. The program is devised into 3 parts; main(), class student.cpp, header student.h



Cry | :((
//student.cpp
#include <iostream>
#include <string>
#include "student.h"

using namespace std;

class student
{
public:

void setInfo(string fname, string lname, int grade); //funtion to assign values to an instance of student
string getName(); //function to retreive the value of first & last name
int getGrade(); //function to retrieve the numerical value of the test score
student(); //default constructor
student(string first, string last, int gradeScore)

string first;
string last;
int gradeScore;
}






//Header file for class student
#ifndef H_student
#define H_student

#include <string>
#include <iostream>

using namespace std;

student::student(string first, string last, int gradeScore)
{
first = fname;
last = lname;
gradeScore = grade;
}

student::student()
{
first = " ";
last = " ";
grade = 0;
}

void student::setInfo(string fname, string lname, int grade)
{
first = fname;
last = lname;
gradeScore = grade;
}

string student::getName()
{
fname = first;
lname = last;

return (first, last);
}

int student::getGrade()
{
grade = gradeScore;

return gradeScore;
}

private:
int gradeScore;
string first;
string last;

#endif






//main()
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include "student.h"

using namespace std;

vector<student> studentList;

int getAverage(vector<student> studentList);
void displayAverage(int avg);
void displayUnderAvg(vector<student> studentList, int avg)
void displayTopStudent(vector<student> studentList);

int main()
{
string firstName;
string lastName;
int score;
int i;
int size;
int average;

student sTemp;

cout << "How many students do you want to enter: ";
cin >> size;
cout << endl << "Please enter the first and last name of the student"
<< endl << "followed by their numerical test grade from 0-100."
<< endl << "(example: David Miotke 98);

for (i=0; i < (size-1); i++)
{
cout << "Enter info for student #" << (i+1) << ": ";
cin >> firstName >> lastName >> score;
sTemp.setInfo(firstName, lastName, score);
studentList.push_back(sTemp);
}

average = getAverage(vector<student> studentList);
displayAverage(average);
displayUnderAvg(vector<student> studentList, average);
displayTopStudent(vector<student> studentList);

return 1
}

int getAverage(vector<student> studentList)
{
unsigned int count;
int sAverage;
int total = 0;

student stud;

for (count = 0; count < studentList.size(); count++)
{
stud.setInfo(studentList[count]);
total = (total + stud.getGrade());
}
sAverage = (total / studentList.size());
return sAverage;
}

void displayAverage(int avg)
{
cout << "The average test score is " << avg << "%" << endl;
}

void displayUnderAvg(vector<student> studentList, int avg)
{
unsigned int count;

student stud;

for (count = 0; count < studentList.size(); count++)
{
stud.setInfo(studentList[count]);
if (stud.getGrade() < avg)
cout << "The following students have scored under the test average:" << endl;
<< stud.getName() << " (" << stud.getGrade() << "%)" << endl;
}
}

void displayTopStudent(vector<student> studentList)
{
unsigned int count;
int top = 0;

student stud;
student st;

for (count = 0; count < studentList.size(); count++)
{
stud.setInfo(studentList[count]);
if (stud.getGrade() > top)
{
top = stud.getGrade();
st.setInfo(studentList[count];
}
}
cout << "The top scoring student is..." << endl
<< st.getName() << " (" << top << "%)" << endl;
}
AnswerRe: Trouble with vectors. Newbie needs help! Pin
Maxwell Chen20-Aug-07 5:05
Maxwell Chen20-Aug-07 5:05 
AnswerRe: Trouble with vectors. Newbie needs help! Pin
David Crow20-Aug-07 5:20
David Crow20-Aug-07 5:20 
AnswerRe: Trouble with vectors. Newbie needs help! [modified] Pin
Graham Shanks20-Aug-07 5:37
Graham Shanks20-Aug-07 5:37 
Questionfopen and wfopen Pin
George_George20-Aug-07 4:35
George_George20-Aug-07 4:35 
QuestionRe: fopen and wfopen Pin
David Crow20-Aug-07 4:39
David Crow20-Aug-07 4:39 
AnswerRe: fopen and wfopen Pin
George_George20-Aug-07 5:00
George_George20-Aug-07 5:00 
QuestionRe: fopen and wfopen Pin
David Crow20-Aug-07 5:18
David Crow20-Aug-07 5:18 
AnswerRe: fopen and wfopen Pin
George_George20-Aug-07 17:43
George_George20-Aug-07 17:43 
GeneralRe: fopen and wfopen Pin
David Crow21-Aug-07 2:55
David Crow21-Aug-07 2:55 
GeneralRe: fopen and wfopen Pin
George_George21-Aug-07 3:09
George_George21-Aug-07 3:09 
GeneralRe: fopen and wfopen Pin
David Crow21-Aug-07 3:21
David Crow21-Aug-07 3:21 
AnswerRe: fopen and wfopen Pin
Paresh Chitte20-Aug-07 20:09
Paresh Chitte20-Aug-07 20:09 
GeneralRe: fopen and wfopen Pin
George_George20-Aug-07 20:28
George_George20-Aug-07 20:28 
GeneralRe: fopen and wfopen Pin
Paresh Chitte21-Aug-07 18:19
Paresh Chitte21-Aug-07 18:19 
GeneralRe: fopen and wfopen Pin
George_George21-Aug-07 20:59
George_George21-Aug-07 20:59 
QuestionTimeout settings Pin
Daria Faucci20-Aug-07 4:25
Daria Faucci20-Aug-07 4:25 
GeneralPlain C++ equivalent of FileSystemWatcher [modified] Pin
benjymous20-Aug-07 4:15
benjymous20-Aug-07 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.