943,807 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 664
  • C++ RSS
Sep 11th, 2009
0

Value returning functions with one or more value parameters

Expand Post »
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?????????

C++ Syntax (Toggle Plain Text)
  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. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
JETFUSION is offline Offline
7 posts
since Sep 2009
Sep 11th, 2009
-7

Re: Value returning functions with one or more value parameters

>>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 ?
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Sep 11th, 2009
1

Re: Value returning functions with one or more value parameters

< 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.
Reputation Points: 673
Solved Threads: 125
Practically a Posting Shark
Sky Diploma is offline Offline
818 posts
since Mar 2008
Sep 11th, 2009
0

Re: Value returning functions with one or more value parameters

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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Sep 11th, 2009
0

Re: Value returning functions with one or more value parameters

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).
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: "Parallel" execution of functions
Next Thread in C++ Forum Timeline: C++ Todo





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC