[| -- C++ Experts Help: Looping/Inputting data (fstream) -- |]

Hey Guys

I have to make a program where it accepts/denies applications into a club. [B]The program should read in information about applicants (None was given so I believe I have to make up some applicant info in Notepad) and output a statement of acceptance or rejection for each applicant. [/B]

[B]Each input line contains the follwing information about the applicant:[/B]
[list]
[*]Applicant's ID number (0-9,999)
Age (0-120)
Score on the Test of Social Skills (0-100)
Score on the literature Art and History test (0-100)
Yearly Income (5,000 - 9,999,999)
An indication of whether the applicants parents where already in the club (y/n)
[/list]

There are 4 judges and each Judge vote for different things:
[list]
[*]Judge 1 votes to accept any candidate who averages 90 or better on the 2 tests.
Judge 2 votes to accept any candidate whose income, in thousands of dollars, exceeds twice his or her age.
Judge 3 votes to accept any candidate who scores at least an 85 on the social skills test and who parents have been inthe Club.
Judge 4 always disagrees with Judge 3 with the exception that she always approves an applicant who is under 35 years old and earns more thank $200,000.
[/list]

In the event of a tie the judges have to take a second vote. At that point judge 3 lower her social skills test requirement down to 75 if Judge 2 had voted to accept the candidate. If the vote is still split, the candidate is not accepted, but is encouraged to reapply in 3 years.

The output format says that the program should echo-print the input then output the judges votes and the final decision. In the case of a split decision, both sets of votes should be printed out. If the candidate is too young or has failed the exams, a message of ineligibility is printed (no vote is taken). If an invalid value is read in (ex: age = 200 or income = $2000), the program should print out an error message and go on to the next applicant.

[B]My teacher mentioned something about using notepad or excel to input data in compliance with an header, only problem is I don't know how. Plus, when I put in my code it just says "Input Candidate's ID #"[/B]

[img=http://i231.photobucket.com/albums/ee44/HalfAmazin89/CandidatesID.png]

Here's my code:

[CODE]#include
#include

using namespace std;

int main (){
int num, age, social, art, income;
int dec;
int tievote;
int i;

char parents;
ofstream results;
results.open("/Users/putyoursoxon/Documents/results.txt");//application results go here

for(i = 1; i <= 3; i ++)
{
dec = 0;
cout << "Input canidate's ID #" << endl;
cin >> num;
cout << "Input canidate's age" << endl;
cin >> age;
cout << "Input canidate's social skills test score" << endl;
cin >> social;
cout << "Input canidate's art and history test score" << endl;
cin >> art;
cout << "Input canidate's income" << endl;
cin >> income;
cout <<"Are canidate's parents in the WTS?" << endl;
cin >> parents;
results << "Canidate ID#" << num << ", Age =" << age << ", Social skils test score =" << social << endl;
results << "Art and history test score =" << art << ", Income =$" << income << ", Parents in WTS? =" << parents << endl;
results << endl;
//display input data
if ( age < 30 || age > 120 || social < 60 || social > 100 || art < 60 || art > 100 || income < 5000 || income > 9999999 || parents != 'y' && parents != 'n')
results << "There is a error in the data" << endl;
else if ( age < 0 || age > 120)
results << "The age of canidate ID#" << num << " is invalid" << endl;

else if (social < 0 || social > 100)
results << "The social skills test score of canidate ID#" << num << " is invaid" << endl;

else if ( art < 0 || art > 100)
results << "The art and history test score of canidate ID#" << num << " is invalid" << endl;

else if (income < 5000 || income > 9999999)
results << "The yearly income of canidate ID#" << num << " is invalid" << endl;

else if (parents != 'y' && parents != 'n')
results << "The input for status of canidate ID#" << num << " parents is not a valid input" << endl;
//Checks that the input data is within the range required

else if ( age < 30)
results << "Canidate ID#" << num << " is not old enough to apply. Please reapply in " << 30 - age << " years" << endl;

else if ( social < 60)
results << "Canidate ID#" << num << " has failed the social skills test and cannot apply" << endl;

else if ( art < 60)
results << "Canidate ID#" << num << " has failed the art and history test and cannot apply" << endl;

else
if ( ((social + art) / 2) >= 90)
dec ++;
if ( (income / 1000) > (age * 2))
dec ++;
if (parents = 'y' && social >= 85)
dec ++;
if (age < 35 && income > 200000 || parents != 'y' || social < 85)
dec ++;
if (dec>2)
results << "Canidate ID#" << num << " has been accepted into the Windsor Tea Society with " << dec << " votes. Congratulations!" << endl;
else if (dec<2)
results << "Canidate ID#" << num << " has not been accepted into the Winsor Tea Society with only " << dec << " votes. Sorry :-(" << endl;
else
results <<"Its a tie!"<< endl;
}


results.close();
return 0;
}[/CODE]

Can You guys please help?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories