Click here to Skip to main content
15,915,042 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: TimerQueueTimers..A question.. Pin
Mark Salsbery31-Aug-08 7:12
Mark Salsbery31-Aug-08 7:12 
QuestionRe: TimerQueueTimers..A question.. [modified] Pin
montiee1-Sep-08 8:39
montiee1-Sep-08 8:39 
QuestionCode efficiency Pin
Evgeni5731-Aug-08 5:26
Evgeni5731-Aug-08 5:26 
AnswerRe: Code efficiency Pin
Robert.C.Cartaino31-Aug-08 7:32
Robert.C.Cartaino31-Aug-08 7:32 
AnswerRe: Code efficiency Pin
Mark Salsbery31-Aug-08 7:35
Mark Salsbery31-Aug-08 7:35 
GeneralRe: Code efficiency Pin
Evgeni5731-Aug-08 22:17
Evgeni5731-Aug-08 22:17 
GeneralRe: Code efficiency Pin
Mark Salsbery1-Sep-08 7:58
Mark Salsbery1-Sep-08 7:58 
Questionc++ function help Pin
anjoz96631-Aug-08 4:07
anjoz96631-Aug-08 4:07 
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void OpenFiles(char ch, float gpa);
void initialize(int fcout, int mcout, float fgpa, float mgpt);
void sumGrades( int fcout, int mcout, float fgpa, float mgpa);
void averageGrades(float avfgpa, float avmgpa);
void printResults(int fcout, int mcout, float avfgpa, float avmgpa);
void main()

{
ofstream out;
ifstream in;
char ch;
float gpa;
float avfgpa;
float avmgpa;
int fcout, mcout;
float fgpa; //define female GPA
float mgpa; //define male GPA

initialize (fcout, mcout, fgpa, mgpa);

OpenFiles(ch, gpa);

while(!in.eof())
{
sumGrades(fgpa,mgpa,fcout,mcout);
in>>ch>>gpa;
averageGrades(avfgpa, avmgpa);

}


printResults(fcout, mcout, avfgpa, avmgpa);


return;

}

void OpenFiles(char ch, float gpa)
{

ofstream out;
ifstream in;
in.open("k:\\prob-7.txt",ios::in);
if (!in)
{
cout<<"Can not open input file"<<endl;
cout<<"program terminates!!"<<endl;
}
in.get(ch);
in>>gpa;
in.eof();

out.open("k:\\out.txt", ios::out);
out<<fixed<<showpoint;
out<<setprecision(2);
//out<<"Female" <<ch<<endl;

}

void initialize(int fcout, int mcout, float fgpa, float mgpa)

{

fgpa = 0.0;
mgpa= 0.0;
fcout = 0;
mcout = 0;
}

void sumGrades(int fcout, int mcout, float fgpa, float mgpa)
{

char ch;
float gpa;
OpenFiles(ch, gpa);
switch (ch)
{
case 'F':
case 'f': fgpa = fgpa+gpa;
fcout++;
//avfgpa = fgpa/fcout;
break;
case 'M':
case 'm': mgpa = mgpa + gpa;
mcout++;
//avmgpa = mgpa/mcout;
break;
default: cout<<"invalid gender"<<endl;
return;
}

}

void averageGrades(float avfgpa, float avmgpa)
{

float fgpa, mgpa;
int fcout, mcout;
sumGrades(fcout, mcout, fgpa, mgpa);
avfgpa = fgpa/fcout;
avmgpa = mgpa/mcout;
}

void printResults(int fcout, int mcout, float avfgpa, float avmgpa)
{
ofstream out;
out<<"Number of female ="<<fcout<<endl;
out<<"Average female GPA = "<<avfgpa<<endl;
out<<"Number of male ="<<mcout<<endl;
out<<"Average male GPA ="<<avmgpa<<endl;
out.close();
}


give a lots of error vs warning, I think that having trouble with function calls, and passing to main function, but i have no idea to fix cause the book i am studying hasnt clear out much.

summerize what program will do :

open a file with 2 columes; one is letter of f or m (represent for female and male), the other colume is GPA (grade).

read it and sum the gpa of female , sum the gpa of male, and display the everage of female and male gpa.

the function calls need to have 5 of them:

initialize variable

open and format output

sum gpa of female and male

find the average of female male gpa

print the rerults.
AnswerRe: c++ function help Pin
Cedric Moonen31-Aug-08 5:42
Cedric Moonen31-Aug-08 5:42 
QuestionSTL exception Pin
followait30-Aug-08 23:04
followait30-Aug-08 23:04 
AnswerRe: STL exception Pin
Mark Salsbery31-Aug-08 7:47
Mark Salsbery31-Aug-08 7:47 
GeneralRe: STL exception Pin
followait31-Aug-08 18:00
followait31-Aug-08 18:00 
Questionifstream question Pin
followait30-Aug-08 16:40
followait30-Aug-08 16:40 
QuestionInvert ARGB [modified] Pin
bob1697230-Aug-08 7:12
bob1697230-Aug-08 7:12 
AnswerRe: Invert ARGB Pin
Mark Salsbery30-Aug-08 8:04
Mark Salsbery30-Aug-08 8:04 
GeneralRe: Invert ARGB Pin
bob1697230-Aug-08 11:52
bob1697230-Aug-08 11:52 
GeneralRe: Invert ARGB Pin
Mark Salsbery30-Aug-08 11:58
Mark Salsbery30-Aug-08 11:58 
QuestionLooking for C++ CWnd equivalent of C#'s Control.Invoke, Control.IsInvokeRequired Pin
Ohad Maishar30-Aug-08 6:13
Ohad Maishar30-Aug-08 6:13 
AnswerRe: Looking for C++ CWnd equivalent of C#'s Control.Invoke, Control.IsInvokeRequired Pin
Mark Salsbery30-Aug-08 6:46
Mark Salsbery30-Aug-08 6:46 
Questionopening network connections Pin
VCProgrammer30-Aug-08 1:50
VCProgrammer30-Aug-08 1:50 
AnswerRe: opening network connections Pin
Dr. Emmett Brown30-Aug-08 3:34
Dr. Emmett Brown30-Aug-08 3:34 
QuestionRe: opening network connections Pin
David Crow30-Aug-08 4:30
David Crow30-Aug-08 4:30 
AnswerRe: opening network connections Pin
Mark Salsbery30-Aug-08 6:41
Mark Salsbery30-Aug-08 6:41 
GeneralRe: opening network connections Pin
VCProgrammer31-Aug-08 20:16
VCProgrammer31-Aug-08 20:16 
GeneralRe: opening network connections Pin
VCProgrammer31-Aug-08 20:41
VCProgrammer31-Aug-08 20:41 

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.