Note: read the contestants name and scores from an input file
There will be 5 contestants
The program will need the following functions:
void getJudgeData() reads the name of the contestant and his or her scores. The name and scores should be saved in a reference parameters and should be validated (between 0 and 10)
void calcScore() should calculate and display the name and average of the three scores that remain after dropping the highest and lowest scores the performer received. This function should be passed the five scores.
The last two functions will be called by calcScore which uses the returned information to determine which of the scores to drop
int findLowest() should find and return the lowest of the five scores passed to it.
int findHighest() should find and return the highest of the five scores passed to it.
Finally, write a function winner, that takes the contestants average scores and prints the name and average score of the winner
this is my program and i have to read the inputs form file. input file containing the name and scores.
i am stuck on reading name and scores form file can any one help me?
this is my code:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<string>
using namespace std;
void getJudgeData(char&,char&,double&,double&,double&,double&,double&);
int main()
{
char fName[20];
char lName[20];
double marks1=0.0,marks2=0.0,marks3=0.0,marks4=0.0,marks5=0.0;
getJudgeData(fName,lName,marks1,marks2,marks3,marks4,marks5);
return 0;
}
void getJudgeData(char &firstName,char &lastName,double &m1,double &m2,double &m3,double &m4,double &m5)
{
ifstream infile;
infile.open("stars.txt");
if(!infile)
{
cout<<"Error!File not found.";
exit(1);
}
cout<<setprecision(2)<<showpoint<<fixed;
for(int i=1;i<=5;i++)
{
infile>>firstName;
infile>>lastName;
infile>>m1>>m2>>m3>>m4>>m5;
}
for(int i=1;i<=5;i++)
{
cout<<firstName;
cout<<lastName;
cout<<m1<<m2<<m3<<m4<<m5;
}
}
This post has been edited by JackOfAllTrades: 26 May 2010 - 03:08 PM
Reason for edit:: Added code tags.

New Topic/Question
Reply
MultiQuote









|