Patient Fees

Here's my code:

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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

class PatientAccount
{
	private:
		float dailyRate;
		int patientNumber;
		int days;
		string patientName;

	public:
		PatientAccount(float, int, int, string);
		float getDailyRate();
		int getPatientNumber();
		int getDays();
		string getPatientName();
		void getPatientDisplay(float& totalCost);
}

PatientAccount::PatientAccount(float dr = 0, int pnum = 0, int dy = 0, string pn = " ")
{
	dailyRate = dr;
	patientNumber = pnum;
	days = dy;
	patientName = pn;
}

float PatientAccount::getDailyRate()
{
	cout << "Enter the daily rate for each day in the hospital: $";
	cin >> dailyRate;

	return dailyRate;
}

int PatientAccount::getPatientNumber()
{
	cout << "Enter the patients number: ";
	cin >> patientNumber;

	return patientNumber;
}

int PatientAccount::getDays()
{
	cout << "Enter the amount of days spent in the hospital: ";
	cin >> days;

	return days;
}

string PatientAccount::getPatientName()
{
	cout << "Enter the patients name: ";
	getline(cin, patientName);

	return patientName;
}

class Surgery
{
	private:
		float surgeryCost;
		string surgeryType;
		
	public:
		Surgery(float, string);
		float getCost();
		string getSurgeryType();
		void getSurgeryDisplay(float& totalCost1);
};

Surgery::Surgery(float co = 0, string st = " ")
{
	surgeryCost = co;
	surgeryType = st;
}

float Surgery::getCost()
{
	cout << "Enter the total cost of surgery: $";
	cin >> surgeryCost;

	return surgeryCost;
}

string Surgery::getSurgeryType()
{
	cout << "Enter the name of the surgery type: ";
	getline(cin, surgeryType);

	return surgeryType;
}

class Pharmacy
{
	private:
		float medCost;
		string medName;

	public:
		Pharmacy(float, string);
		float getMedCost();
		string getMedName();
		void getPharmacyDisplay(float& totalCost2);
};

Pharmacy::Pharmacy(float mc = 0, string mn = " ")
{
	medCost = mc;
	medName = mn;
};

float Pharmacy::getMedCost()
{
	cout << "Enter the cost of the mdeciation: $";
	cin >> medCost;

	return medCost;
}

string Pharmacy::getMedName()
{
	cout << "Enter the medication name: ";
	getline(cin, medName);

	return medName;
}

void PatientAccount::getPatientDisplay(float& totalCost)
{
	PatientAccount patient(getDailyRate(), getPatientNumber(), getDays(), getPatientName());

	totalCost = days * dailyRate;

	cout << "\n";
	cout << "Patient Name:              " << patientName << endl;
	cout << "Patient Number:            " << patientNumber << endl;
	cout << "Days:                      " << days << endl;
	cout << "Daily Rate:               $" << dailyRate << endl;
	cout << "Total Cost:               $" << totalCost << endl;
	cout << "\n";
}

void Surgery::getSurgeryDisplay(float& totalCost1)
{
	Surgery patient(getCost(), getSurgeryType());

	totalCost1 = surgeryCost;

	cout << "Surgery Type:              " << surgeryType << endl;
	cout << "Surgery Cost:             $" << surgeryCost << endl;
	cout << "Total Cost:               $" << totalCost1 << endl;
	cout << "\n";
}

void Pharmacy::getPharmacyDisplay(float& totalCost2)
{
	Pharmacy patient(getMedCost(), getMedName());

	totalCost2 = medCost;

	cout << "Medication Name:           " << medName << endl;
	cout << "Medication Cost:          $" << medCost << endl;
	cout << "Total Cost:               $" << totalCost2 << endl;
	cout << "\n";
}

int main(float totalCost, float totalCost1, float totalCost2)
{
	float totalCost3;

	PatientAccount patient;
	Surgery patient1;
	Pharmacy patient2;

	patient.getPatientDisplay(totalCost);
	patient1.getSurgeryDisplay(totalCost1);
	patient2.getPharmacyDisplay(totalCost2);

	totalCost3 = ((totalCost + totalCost2) + totalCost2);
	cout << "Total Cost Hospital:     $" << totalCost3 << endl;
	cout << "\n";

	cout << endl << "Press ENTER to exit...";
	cin.clear();
	cin.sync();
	cin.get();

	return 0;
}


I'm getting an error on line 24 saying constuctors not allowed a return type, anyone see why that error is showing, because i cant find it.
Last edited on
Nevermind, i found it forgot a ; at

class PatientAccount
{



} right here;
Last edited on
I am still having a problem though, the program runs fine, but when it get toe the pharmacy and surgery user input it skips allowing me to the med name and surgery type string and just lets me enter the costs, how can i fix this.
Any ideas?
Ok, im all out of ideas to try, if anyone knows why let me know.
Topic archived. No new replies allowed.