473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

frustrating problem,help please!!!

5 New Member
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.tha nx
May 27 '07 #1
4 1518
Savage
1,764 Recognized Expert Top Contributor
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
64 New Member
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.tha nx
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
cyborg81
5 New Member
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
1,764 Recognized Expert Top Contributor
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

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

Similar topics

7
1489
by: Francis Bell | last post by:
Hello, I've got a 25 line file with lines of data like this: sp/spinnerbait/AAA Lures/Mad Phil/silver/bass/1/1 The first field is the code that determines what to do. I need to loop through this data file and, based on that first field, execute different cases in a switch statement (yes, there's only one now...I'm in a building process, and I need to get the first one to read first.). However, it's only going through 1 time and it should...
5
4601
by: trint | last post by:
Ok, Everything connects correctly and loads properly in this WebApplication. I have four buttons and all work correctly except one (the NEXT RECORD button). PREVIOUS, FIRST and LAST all work properly. This identical code works correctly in a windows app. Please tell me what I am doing wrong. Here is my connection code: private void InitializeDataConnection ()
4
6204
by: Madhu Gopinathan | last post by:
Hi All, I am faced with a horrible hang problem. I have a COM exe server that executes some tasks. The task execution manager is a thread that manages the pool of threads, which is 4 per processor. Each task is processed in a separate thread. Each of the executer threads is an STA thread, and it goes ahead and executes the task. No problems are encountered when tasks are executed one at a time, but when multiple tasks are executed...
2
2526
by: feng zhu | last post by:
Hi All, I''m using c# in asp.net and I tried to encode some upper part of ASCII chars, eg. á The desired result should be: %E1 But when I use HttpUtility.UrlEncode("á"), the output result is: %c3%a1 I tried ISO 8859-1 and utf-8, neither works. anybody can help me? Or other way to do it, javascript escape?no experice with that thanks for any help Feng
1
1377
by: Simon Harvey | last post by:
Hi, I'm hoping someone can help me witht he following problem: I have a fairly simple page that has a sort form and a button for adding the forms details to an arraylist. When the button is pressed, the information from the form needs to be added to a list in the bottom half of the page.
3
1739
by: TycoonUK | last post by:
Hi, I am having trouble with the U. K. - 70th Anniversary link on my website when under internet explorer where this page crashes i.e. This has happened since I started to use my new CSS Menu and I wondered if anyone can help me. Many thanks in advance
4
2002
by: russell.hunter | last post by:
I have pear installed on my web server. The problem is, I can't seem to get it working! Whenever I try to call one of the installed packages, for example: require_once "DB.php"; I get the following error: Warning: main(): open_basedir restriction in effect.
2
5646
by: sharonrao123 | last post by:
product page has datalist control with paging implemented by gridview control, ProductDetail is the second page with back button which will take the user to the previous page. The problem is when i go to second page in the datalistcontrol and click back button in productdetail page, even the browser back button dosent work, the previous page is not displayed and gives me "Page not found" Error. Any ideas how to make it work <input...
7
3370
by: Lynn | last post by:
Hello, I have a website that is working fine. I have just turned on "option strict" and am getting an error with the parts of my code. I have fixed everything but this section, which has me baffled. I am getting the error "option Strict On disallows late binding", and the error is referring to this line of code: (3rd line in my sub below) Select Case sender.Parent.ID
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.