Value returning functions with one or more value parameters

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2009
Posts: 7
Reputation: JETFUSION is an unknown quantity at this point 
Solved Threads: 0
JETFUSION JETFUSION is offline Offline
Newbie Poster

Value returning functions with one or more value parameters

 
0
  #1
Sep 11th, 2009
The IT firm ITEnterprizes has a unique way of deciding whether an applicant for a post should be invited for an
interview or not. The decision depends on the candidate’s qualifications, age and years of experience and is made as
follows: a certain weight is assigned to each of these aspects and the total is determined. All candidates with a rating
above 44 are invited for an interview.
You have to develop a C++ program to do the above. It will be done in three steps. You need to submit the program
and output of question 3c only. You will see that we declare a global constant.

Question 3a: Start small
We give the main function below. Your task is to write three functions, namely qualFactor, ageFactor and
experFactor, all of return type int. Each of these functions has one value parameter.
The function qualFactor receives a char value. The character U indicates a university degree and a weight
of 40 should be returned. The character D indicates a diploma and a weight of 30 should be returned. The
character M indicates that the candidate has passed Grade 12 at school and a weight of 20 should be returned.
If any other character is received, a weight of 0 should be returned. Use a switch statement in this
function.
The function ageFactor receives an int value, namely the age. If the candidate is older than 22 but younger
than 40, a weight of 10 should be returned. If the candidate is 40 years or older but not older than 55, a
weight of 5 should be returned. A weight of 0 should be returned in all other cases..
The function experFactor receives an int value, namely the years experience. If the candidate has 10 or
more years experience, a weight of 20 should be returned. If the candidate has less than 10 but more than 5
years experience, a weight of 10 should be returned. Otherwise a weight of 0 should be returned.

Question 3b: Still small
Now write another value returning function, namely interviewOrNot, of return type bool. There are three
value parameters. The function receives the three weights that were assigned to the qualification, age and years
experience, respectively, and then has to determine whether the candidate should be invited to an interview. If so,
the value true has to be returned. If not, the value false has to be returned. We give the main function again.

Question 3c: Add a loop to the main function
Write a program containing the functions qualFactor, ageFactor, experFactor and interviewOrNot
that you wrote in 3a and 3b. The program has to process a list of applications and display the applicable message for
every application. You may use the main function of 3b but you will have to change it as it should now contain a
for loop. Run your program on the list of 9 applications below and submit printouts of the program and output.

This is what i have but not working?????????

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int CUT_OFF = 44;
  5.  
  6. void inputAndValidate (int & ageFactor, int & experFactor, int & interviewOrNot,
  7. char & qualFactor)
  8.  
  9. int main( )
  10. {
  11. char qual;
  12. int age, exper, qualWeight, ageWeight, experWeight;
  13. bool invite;
  14.  
  15. cout << "Highest qualification " << endl << "Enter U (degree), or "
  16. << " D (diploma), or M (grade 10); otherwise any character: ";
  17. cin >> qual;
  18. cout << "Age: ";
  19. cin >> age;
  20. cout << "Years experience: ";
  21. cin >> exper;
  22.  
  23. qualWeight = qualFactor(qual);
  24. ageWeight = ageFactor(age);
  25. experWeight = experFactor(exper);
  26.  
  27. invite = interviewOrNot (qualWeitght, ageWeight, experWeight);
  28. if (invite)
  29. cout << "Candidate should be invited for an interview."
  30. << endl;
  31. else
  32. cout << "Candidate is unsuccessful." << endl;
  33.  
  34. return 0;
  35. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,571
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1485
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Value returning functions with one or more value parameters

 
-7
  #2
Sep 11th, 2009
>>This is what i have but not working?????????

Well, what is it that is not working? Doesn't it compile? If not then what are the error message(s)? And what compiler are you using ?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 677
Reputation: Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold 
Solved Threads: 101
Sky Diploma's Avatar
Sky Diploma Sky Diploma is offline Offline
Practically a Master Poster

Re: Value returning functions with one or more value parameters

 
1
  #3
Sep 11th, 2009
< SNIPPED > AS I learnt it provided misleading steps to the OP. </SNIPPED >
Last edited by Sky Diploma; Sep 11th, 2009 at 12:05 pm. Reason: Snipping the total post.
1. Please Mark Your Thread as Solved After Getting Your Answers.
2. Please Use CODE TAGS .
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,738
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 281
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Value returning functions with one or more value parameters

 
0
  #4
Sep 11th, 2009
Declare and define functions before calling them. As your directions instruct don't even try wirting inviteOrNot() until you have the other 3 functions up and running.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Value returning functions with one or more value parameters

 
0
  #5
Sep 11th, 2009
Well it won't compile by simple visual inspection.

Then there's the whole "let's magic some functions to do the interesting work simply by naming them" (which of course, doesn't work either).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC