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?

Recommended Answers

All 7 Replies

Sorry, but it's impossible to read your snippet.
Please, use code tag properly:
[code=c++] sources (with line breaks)

[/code]

// 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

Are you sure that this typo nightmare is better than previous one?
Once more:
[code=c++] source(s) (with line breaks!!!)

[/code]

#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
#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

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.

i have the source code for this. It is a basic only
if you want just leave a message..

i want the source code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.