Having problems with my code

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

Join Date: Oct 2008
Posts: 57
Reputation: cassie_sanford is an unknown quantity at this point 
Solved Threads: 0
cassie_sanford cassie_sanford is offline Offline
Junior Poster in Training

Having problems with my code

 
0
  #1
Mar 28th, 2009
I have to write a program that must compute and display the charges for a patients hospital stay. first the program should ask if the patient was admitted as an in patient or an out patient. If the patient was as an in-patient the following data should be entered:
the number of days spent in the hospital
the daily rate
charges for hospital services (lab tests, etc.)
hospital medication charges

If the patient was an out patient the following data should be entered:
charges for hospital services (lab tests, etc.)
hosppital medication charges

the program should use two overloaded functions to calculate the total charges. one of the functions should accept arguments for the in patient data, while the other function accepts arguments for out patient data. Both functions should return the total charges.
Input validation: do not accept negative numbers for any information. Im having trouble getting my data to come out right.

And this is what I have to far:
// This program computes and displays patient hospital charges.// It uses overloaded functions.#include <iostream>#include <iomanip>using namespace std;// Function prototypesdouble patientCharges(int, double, double, double); // In-patientdouble patientCharges(double, double);			   	 // Out-patientint main(){	char patientType;	          // I=in-patient, O=out-patient	int  days;						 // Number of days of hospital stay	double roomRate,	          // Daily room rate	       medication,          // Total medication charges          services,            // Total for tests and other services          totalCharges;	       // Total of all charges	// Input and validate patient type   cout << "This program will compute patient hospital charges.\n";	cout << "Enter I for in-patient or O for out-patient: ";   cin  >> patientType;			//add code here	     	 // Input and validate data relevant to in-patients			//add code here   	// Input and validate data relevant to all patients   		//add code here  	// Call correct patientCharges function to return total charges			//add code here    	// Display the billing statment	cout << fixed << showpoint << setprecision(2) << endl << endl;   cout << "******************************\n";   if (patientType == 'I')      cout << "Room charges    $" << setw(8) << days*roomRate << endl;   if (services > 0.0)      cout << "Lab & Services  $" << setw(8) << services << endl;   if (medication > 0.0)      cout << "Medication      $" << setw(8) << medication << endl;   cout    << "Total charges   $" << setw(8) << totalCharges << endl;	cout << "******************************\n";   	return 0;}// End of main function/************************************************************* *                        patientCharge                      * * This function is called by main to calculate and return   * * total patient charges for in-patients                     * *************************************************************/double patientCharges(int days, double rate, double med, double serv){	//add code here}// end overload function patientCharges/************************************************************* *                        patientCharge                      * * This function is called by main to calculate and return   * * total patient charges for out-patients                    * *************************************************************/double patientCharges(double med, double serv){		//add code here}// end overload function patientCharges

can anyone help?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Having problems with my code

 
0
  #2
Mar 28th, 2009
Sorry, but it's impossible to read your snippet.
Please, use code tag properly:
[code=c++]
sources (with line breaks)
[/code]
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 57
Reputation: cassie_sanford is an unknown quantity at this point 
Solved Threads: 0
cassie_sanford cassie_sanford is offline Offline
Junior Poster in Training

Re: Having problems with my code

 
0
  #3
Mar 28th, 2009
// This program computes and displays patient hospital charges.
// It uses overloaded functions.
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes double patientCharges(int, double, double, double); 
// In-patientdouble patientCharges(double, double);			   	 
// Out-patientint main()
{	
char patientType;	          
// I=in-patient, O=out-patient	int  days;						
// Number of days of hospital stay	double roomRate,	          
// Daily room rate	       medication,         
 // Total medication charges          services,          
  // Total for tests and other services          
totalCharges;	       // Total of all charges	
// Input and validate patient type   cout << "This program will compute patient hospital charges.\n";	
cout << "Enter I for in-patient or O for out-patient: ";   
cin  >> patientType;			
//add code here	     	 
// Input and validate data relevant to in-patients			
//add code here   	
// Input and validate data relevant to all patients   		
//add code here  	
// Call correct patientCharges function to return total charges			
//add code here    	
// Display the billing statment	
cout << fixed << showpoint << setprecision(2) << endl << endl;   
cout << "******************************\n";   
if (patientType == 'I')      
cout << "Room charges    $" << setw(8) << days*roomRate << endl;   
if (services > 0.0)      
cout << "Lab & Services  $" << setw(8) << services << endl;   
if (medication > 0.0)      
cout << "Medication      $" << setw(8) << medication << endl;   
cout    << "Total charges   $" << setw(8) << totalCharges << endl;	
cout << "******************************\n";   	
return 0;

}// End of main function/************************************************************* *                       
 patientCharge                      
* * This function is called by main to calculate and return   * * total patient charges for in-patients
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Having problems with my code

 
0
  #4
Mar 28th, 2009
Are you sure that this typo nightmare is better than previous one?
Once more:
[code=c++]
source(s) (with line breaks!!!)
[/code]
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 57
Reputation: cassie_sanford is an unknown quantity at this point 
Solved Threads: 0
cassie_sanford cassie_sanford is offline Offline
Junior Poster in Training

Re: Having problems with my code

 
0
  #5
Mar 29th, 2009
[ICODE=c++]

#include <iostream
#include <iomanip>
using namespace std;
//function prototypes
double patientcharges(int, double, double, double);
//in- patient double
patientCharges(double,double);
//out-patient

int main()

{
char patientTye;
//I = in-patient;
//O = out-patient;
int days; //num days of hospital stay
double roomRate;
//Daily room rate
double medication;
// Total medication charges
double services,
// Total for tests and other services
totalCharges;
// Total of all charges
// Input and validate patient type
cout << "This program will compute patient hospital charges
cout << "Enter I for in-patient or O for out-patient: ";
cin >> patientType;
//add code here
// Input and validate data relevant to in-patients
//add code here
// Input and validate data relevant to all patients
//add code here
// Call correct patientCharges function to return total charge
//add code here
// Display the billing statment
cout << fixed << showpoint << setprecision(2) << endl << endl;
cout << "******************************\n";
if (patientType == 'I')
cout << "Room charges $" << setw(8) << days*roomRate<<endl;
if (services > 0.0)
cout << "Lab & Services $" << setw(8) << services << endl;
if (medication > 0.0)
cout << "Medication $" << setw(8) << medication << endl;
cout << "Total charges $" << setw(8) << totalCharges << endl;
cout << "******************************\n";
return 0;
}

//Calculate function that i have no clue how to do
[/ICODE]
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,822
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Having problems with my code

 
0
  #6
Mar 29th, 2009
  1. #include <iostream
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5.  
  6. //function prototypes
  7. double patientcharges(int, double, double, double);
  8. //in- patient double
  9. patientCharges(double,double);
  10. //out-patient
  11.  
  12.  
  13. int main()
  14. {
  15. char patientTye;
  16. //I = in-patient;
  17. //O = out-patient;
  18. int days; //num days of hospital stay
  19. double roomRate;
  20. //Daily room rate
  21. double medication;
  22. // Total medication charges
  23. double services,
  24. // Total for tests and other services
  25. totalCharges;
  26. // Total of all charges
  27. // Input and validate patient type
  28.  
  29.  
  30. cout << "This program will compute patient hospital charges
  31. cout << "Enter I for in-patient or O for out-patient: ";
  32. cin >> patientType;
  33.  
  34.  
  35. //add code here
  36. // Input and validate data relevant to in-patients
  37.  
  38.  
  39. //add code here
  40. // Input and validate data relevant to all patients
  41.  
  42.  
  43. //add code here
  44. // Call correct patientCharges function to return total charge
  45.  
  46.  
  47. //add code here
  48. // Display the billing statment
  49. cout << fixed << showpoint << setprecision(2) << endl << endl;
  50. cout << "******************************\n";
  51. if (patientType == 'I')
  52. cout << "Room charges $" << setw(8) << days*roomRate<<endl;
  53. if (services > 0.0)
  54. cout << "Lab & Services $" << setw(8) << services << endl;
  55. if (medication > 0.0)
  56. cout << "Medication $" << setw(8) << medication << endl;
  57. cout << "Total charges $" << setw(8) << totalCharges << endl;
  58. cout << "******************************\n";
  59.  
  60.  
  61. return 0;
  62. }
  63.  
  64. //Calculate function that i have no clue how to do
  65.  

The coloring of the code immediately alerts you to problems.

Line 9 - doesn't start with purple, so you have forgotten the return type.

Line 31 - cout is in blue, but for is in purple, rather than vice-versa. Almost definitely means you are missing a quotes mark in the previous line.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 30
Reputation: FrancisC07 is an unknown quantity at this point 
Solved Threads: 1
FrancisC07's Avatar
FrancisC07 FrancisC07 is offline Offline
Light Poster

Re: Having problems with my code

 
0
  #7
Mar 30th, 2009
i have the source code for this. It is a basic only
if you want just leave a message..
Last edited by FrancisC07; Mar 30th, 2009 at 1:18 am. Reason: lack of info.
"One more round and it's bottle to the ground"
-NOFX
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



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC