By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

frustrating problem,help please!!!

P: 5
when i compile the following code it gives the following error on the line indicated in bold:

Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cstdlib>
  4.  
  5.  
  6.  
  7. using std::cin;
  8. using std::cout;
  9. using std::endl;
  10. using std::left;
  11. using std::right;
  12. using std::setprecision;
  13. using std::setw;
  14. using std::fixed;
  15.  
  16. void welcome();
  17. int getPatientIndicators();
  18. int readInteger();
  19. void flushStream(void);
  20. int getValidInteger ( int min, int max );
  21. void getYesNoResponse(char &response);
  22. void classifyPatient(int &numCat1, int &numCat2, int &numCat3, int patientPoints);
  23. void displayPatientSummmary(int numCat1, int numCat2, int numCat3, int numPatients);
  24. void displayStaffingSummar(int numcat1, int numcat2, int numcat3);
  25.  
  26.  
  27. int main()
  28. {
  29.     int option = 0;
  30.     int numCat1= 0;
  31.     int numCat2= 0;
  32.     int numCat3= 0;
  33.     int patientPoints = 0;
  34.     int numPatients = 0;
  35.     int numcat1 = 0;
  36.     int numcat2 = 0;
  37.     int numcat3 = 0;
  38.  
  39.     welcome();
  40.     option = getPatientIndicators();
  41.  
  42.     do
  43.     {
  44.  
  45.     if (option == 1)
  46.     {
  47.         classifyPatient(numCat1,numCat2,numCat1,patientPoints);
  48.     }
  49.     else if (option == 2)
  50.     {
  51.         displayPatientSummmary(numCat1,numCat2,numCat3,numPatients);
  52.     }
  53.     else if (option == 3)
  54.     {
  55.         displayStaffingSummar(numcat1,numcat2,numcat3);
  56.     }
  57.     else
  58.     {
  59.         exit(0);
  60.     }
  61.     while (option != 0);
  62.     }
  63.  
  64.     return 0;
  65. }
  66.  
  67.  
  68.  
  69. void welcome()
  70. {
  71.  
  72.  
  73.     cout<<endl<<endl;
  74.     cout<<"Welcome to Base Hospital Nursing Care Program."<<endl<<endl;
  75.     cout<<"Menu Options:"<<endl;
  76.     cout<<"1."<<setw(6)<<"Classify a Patient."<<endl;
  77.     cout<<"2."<<setw(6)<<"Display Patient Data Summary."<<endl;
  78.     cout<<"3."<<setw(6)<<"Display Staffing Summary."<<endl;
  79.     cout<<"0."<<setw(0)<<"Exit."<<endl;
  80.  
  81.  
  82. }
  83.  
  84. int getPatientIndicators()
  85. {    
  86.     int option = 0;
  87.  
  88.     cout<<"Select Option:=> ";
  89.     option = readInteger();
  90.  
  91.     return option;
  92. }
  93.  
  94. int readInteger()    // function definition
  95. {
  96.   int tempInt;    // a local variable
  97.   cin >> tempInt;
  98.   while (cin.fail())
  99.   {
  100.     cin.clear();          // clear input error flags
  101.     flushStream();    // clear to end of line
  102.     cout << "ERROR: You must enter an integer ==> ";
  103.     cin >> tempInt;    // try again
  104.   }
  105.   return tempInt;
  106. }
  107.  
  108. void flushStream(void)            
  109. {
  110.   char temp = ' ';
  111.  
  112.   cin.get(temp);
  113.   while (temp != '\n')
  114.   {
  115.     cin.get(temp);
  116.   }
  117. }
  118.  
  119. int getValidInteger ( int min, int max )
  120. {
  121.     int choice ;
  122.  
  123.     choice = readInteger();
  124.  
  125.     // ensure integer within range
  126.     while ( choice < min || choice > max )
  127.     {
  128.         cout << "Error: please enter a number between " << min 
  129.     << " and " << max << " : " ;
  130.         choice = readInteger () ;
  131.     }
  132.     return choice ;
  133. }
  134.  
  135. void getYesNoResponse(char &response)
  136. {
  137.     cin>>response;
  138.  
  139.     while(!((response=='Y')||(response=='N')||(response=='y')||(response=='n')))
  140.     {
  141.         cout<<"Please Enter(Y or N):";
  142.         cin>>response;
  143.     }
  144. }
  145.  
  146. void classifyPatient(int &numCat1, int &numCat2, int &numCat3, int patientPoints)
  147. {
  148.     int points = 0;
  149.     int hours = 0;
  150.     int points1 = 0;
  151.     int points2 = 0;
  152.     int points3 = 0;
  153.     int points4 = 0;
  154.     int points5 = 0;
  155.     int feed = 0;
  156.     int bath = 0;
  157.     int assist = 0;
  158.     char incon = 0;
  159.     char agg = 0;
  160.  
  161.     cout<<endl<<endl;
  162.     cout<<"Classifying Patient No: "<<endl<<endl;
  163.     cout<<"Enter nutrition care level"<<endl;
  164.     cout<<"[1. Feed with assist, 2. Complete Feeding]==> ";
  165.     feed = readInteger();
  166.  
  167.     if(feed == 1)
  168.     {
  169.         points1 = 3;
  170.     }
  171.     else
  172.     {
  173.         points1 = 5;
  174.     }
  175.     cout<<endl<<endl;
  176.     cout<<"Enter hygiene care level"<<endl;
  177.     cout<<"[1. Bath, self, 2. Bath assisted]==> ";
  178.     bath = readInteger();
  179.  
  180.     if(bath == 1)
  181.     {
  182.         points2 = 2;
  183.     }
  184.     else
  185.     {
  186.         points2 = 5;
  187.     }
  188.     cout<<endl<<endl;
  189.     cout<<"Enter activity care level"<<endl;
  190.     cout<<"[1. Up without assist, 2. Up with assist, 3. Complete Imobility]==> ";
  191.     assist = readInteger();
  192.     if(assist == 1)
  193.     {
  194.         points3 = 2;
  195.     }
  196.     else if(assist == 2)
  197.     {
  198.         points3 = 4;
  199.     }
  200.     else
  201.     {
  202.         points3 = 10;
  203.     }
  204.     cout<<endl<<endl;
  205.     cout<<"Does the patient suffer from incontinence? (Y/N)==> ";
  206.     getYesNoResponse(incon);
  207.     if (incon == 'Y' || incon == 'y')
  208.     {
  209.         points4 = 10;
  210.     }
  211.     else
  212.     {
  213.         points4 = 0;
  214.     }
  215.     cout<<endl<<endl;
  216.     cout<<"Is the patient aggresive (Y/N)==> ";
  217.     getYesNoResponse(agg);
  218.     if (agg == 'Y' || incon == 'y')
  219.     {
  220.         points5 = 10;
  221.     }
  222.     else
  223.     {
  224.         points5 = 0;
  225.     }
  226.     cout<<endl<<endl<<endl;
  227.  
  228.     points = points1+points2+points3+points4+points5;
  229.  
  230.     if (points == 0 || points <=20)
  231.     {
  232.         patientPoints = 3;
  233.     }
  234.     else if (points == 21 || points <= 30)
  235.     {
  236.         patientPoints = 7;
  237.     }
  238.     else
  239.     {
  240.         patientPoints = 12;
  241.     }
  242.  
  243.     cout<<"total care hours"<<patientPoints<<endl;
  244.  
  245. }
  246.  
  247. void displayPatientSummmary(int numCat1, int numCat2, int numCat3, int numPatients)
  248. {
  249.     // now display the output
  250.    cout << endl << endl << setw(40) << "Patient Summary Report" << endl<<endl<<endl;
  251.    cout << setw(15) << left<< "Category" << setw(5) << right << "Care Rates<Hrs>"
  252.        << setw(15) << fixed << setprecision(2) << "#Patients" << setw(15) << right
  253.         << setprecision(2) << "%Distribn." << endl<<endl;
  254.  
  255.    cout << setw(15) << left<< "Category 1" << setw(10) << right << "3"
  256.         << setw(15) << fixed << setprecision(2) << "0" << setw(15) << right
  257.         << setprecision(2) << "0" << endl;
  258.  
  259.    cout << setw(15) << left<< "Category 2" << setw(10) << right << "7"
  260.         << setw(15) << fixed << setprecision(2) << "0" << setw(15) << right
  261.         << setprecision(2) << "0" << endl;
  262.  
  263.    cout << setw(15) << left<< "Category 3" << setw(10) << right << "12"
  264.         << setw(15) << fixed << setprecision(2) << "0" << setw(15) << right
  265.         << setprecision(2) << "0" << endl << endl;
  266.  
  267.  
  268. }
  269.  
  270. void displayStaffingSummar(int numcat1, int numcat2, int numcat3)
  271. {
  272.     int points = 0;
  273.     int nurses = 0;
  274.     const int num = 8;
  275.  
  276.     points = getPatientIndicators();
  277.  
  278.     nurses = points/num;
  279.  
  280.     cout<<"Thus number of nurses needed: "<<setprecision(2)<<nurses<<endl;
  281. }




it gives me a compilation error as:

error C2059: syntax error : 'return'
i cant resolve this no matter what i try,any help will be appreciated.thanx
May 27 '07 #1
Share this Question
Share on Google+
4 Replies


Savage
Expert 100+
P: 1,764
Please improve ur coding style and use code tags
U can't see what problem is if u don't tab in.

U also have one parenthesis more than u need.

I have 'cleaned' ur code a bit,so try it now and remember to use code tags when posting.

Expand|Select|Wrap|Line Numbers
  1.  
  2. do
  3. {
  4.  
  5.   if (option == 1)
  6.   {
  7.     classifyPatient(numCat1,numCat2,numCat1,patientPoi nts);
  8.   }
  9.   else if (option == 2)
  10.   {
  11.     displayPatientSummmary(numCat1,numCat2,numCat3,num Patients);
  12.   }
  13.   else if (option == 3)
  14.   {
  15.     displayStaffingSummar(numcat1,numcat2,numcat3);
  16.   }
  17.   else exit(0);
  18.  
  19. }while (option != 0);
  20.  return 0;
  21.  
  22. }
  23.  
Savage
May 27 '07 #2

nemisis
P: 64
it gives me a compilation error as:

error C2059: syntax error : 'return'
i cant resolve this no matter what i try,any help will be appreciated.thanx
Remove the extra '}' after while (option != 0);

Also i get more errors in your program but not sure if its the whole code here. so if u still have anything else, will be glad to try and solve it
May 27 '07 #3

P: 5
hey guys thanx,as u can makeout im a newbie and still learning,my coding style is not good.but thanx for the tips and help.apreciate it.cheers!
May 27 '07 #4

Savage
Expert 100+
P: 1,764
hey guys thanx,as u can makeout im a newbie and still learning,my coding style is not good.but thanx for the tips and help.apreciate it.cheers!
We are mory than happy to help u.

All u need is to make sure that questions u ask don't violate posting guidelines.

BTW,have u readed them?

If u haven't please read them when u have time.

:)

Savage
May 27 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.