HELP i need this program for a class

this is meant to be a program with 4 functions msin, getPatientType and two patientCharges. its an overloaded function thing. anyway my professor wont explain what im doing wrong so please help


#include<iostream>
#include<iomanip>

using namespace std;


//define general variables
void getChoice(char );
double getCharges(double,int, double, double);
double getCharges(double, double);

int main()

{
//define variables for this function
char patient;
int days;
double rate;
double medicine;
double hospital;

//ask the user for in patient or out patient

cout << fixed << showpoint << setprecision(2);

cout<<"Is this for an In-Patient or Out-Patient?"<< endl;

cout<<"Enter I for in-patient and O for out-patient"<<endl;

getChoice(patient);

//check input
if (!(patient = i || patient =I || patient = o || patient = O))
{
"PLease enter a(n) I or a O"endl;

getChoice (patient);

}

if ( patient = i || patient = I)

{
//if in patient ask for charges
cout <<"How many days did you spend in the hospital?" endl;

cin >> days;

cout <<"What was the daily rate? " endl;

cin >> rate;

cout <<"Medication charges?"endl;

cin >> medicine;

cout <<"Lab fees and other service charges? ";

cin >> hospital;

cout <<"The total charges are " << getCharges(rate, days, medicine, hospital) << "." << endl;

}

if ( patient = o || patient = O)

{
//get charges if out patient

case 'O' :

case 'o' : cout <<"Lab fees and other service charges? " endl;

cin >>hospital;

cout <<"Medication charges? " endl;

cin >>medicine;

cout <<"The total charges are " << getCharges(hospital, medicine) << "." << endl;

}

return 0;

}

//define variables for the math

double charges
double total

{

//do the math
double total= (rate * days) + hospital + medicine;

}


{

//good golly more math
double charges= hospital + medicine;

}

//display info

{


cout << fixed << showpoint << setprecision(2);
cout << "Medication and service charges" << charges << endl;
cout << "Total hospital charges" << total << endl;
}

You are missing semicolons at the end of the following:
1
2
double charges
double total


Also as a side note, you can declare multiple variables of the same type without renaming the type like so:
1
2
double charges,
       total;


not really going to change how the code works, but it is a stylistic choice that I certainly prefer.
Last edited on
After looking in more detail I found quite a few errors that it seems you should be aware of how to fix. Here is what I came up with:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include<iostream>
#include<iomanip>

using namespace std;


//define general variables
void getChoice(char);
double getCharges(double, int, double, double);
double getCharges(double, double);

int main()

{
	//define variables for this function
	char patient;
	int days;
	double rate,
		   medicine,
		   hospital;

	//ask the user for in patient or out patient
	cout << fixed << showpoint << setprecision(2);

	cout << "Is this for an In-Patient or Out-Patient?" << endl;

	cout << "Enter I for in-patient and O for out-patient" << endl;

	getChoice(patient);

	//check input
	// EDIT used assignment operator (=) instead of conditional (==)
	if (!(patient == 'i' || patient == 'I' || patient == 'o' || patient == 'O') )
	{
		// EDIT did not put '<<' in between string ("PLease enter a(n) I or a O") and endl
		cout << "PLease enter a(n) I or a O" << endl;

		getChoice(patient);
	}

	if (patient == 'i' || patient == 'I')

	{
		//if in patient ask for charges
		cout << "How many days did you spend in the hospital?" << endl;

		cin >> days;

		cout << "What was the daily rate? " << endl;

		cin >> rate;

		cout << "Medication charges?" << endl;

		cin >> medicine;

		cout << "Lab fees and other service charges? ";

		cin >> hospital;

		cout << "The total charges are " << getCharges(rate, days, medicine, hospital) << "." << endl;

	}

	if (patient == 'o' || patient == 'O')

	{
		//get charges if out patient
	// EDIT Missing switch(patient) ?
	case 'O':

	case 'o': cout << "Lab fees and other service charges? " << endl;

	cin >> hospital;

	cout << "Medication charges? " << endl;

	cin >> medicine;

	cout << "The total charges are " << getCharges(hospital, medicine) << "." << endl;

	}

	return 0;

}

//define variables for the math

double charges,
	   total;
// EDIT not sure what is suppossed to go here. Overloaded getCharges? Need an identifier
{
	//do the math
	double total = (rate * days) + hospital + medicine;
}

// EDIT again, not sure what is suppossed to go here. Overloaded getCharges? Need an identifier
{
	//good golly more math
	double charges = hospital + medicine;
}

//display info
// EDIT what should go here? A print function? 
{
	cout << fixed << showpoint << setprecision(2);
	cout << "Medication and service charges" << charges << endl;
	cout << "Total hospital charges" << total << endl;
}


Also, please use code tags around anything that is actual code (http://www.cplusplus.com/articles/z13hAqkS/)

Let me know if you have any further troubles.
Topic archived. No new replies allowed.