Assistance

Hi, I'm struggling with a certain program and I need someone to help me with it. I'm not requesting someone to do it for me, but to guide me in the right direction. This is what I have to do:

The table below lists prices (in units) to treat various injuries at the clinic:

Painkillers** 35
Severe Abrasions and Bruising 20
Cuts w/Stiches 60
1st Degree Fractures 150
2nd Degree Fractures 350
Burn Treatment (all degrees) 200
Severed Appendage (Fingers/Toes) 180
Severed Appendages (Arms/Legs) 430
Concussion 45
** All out-patients receive painkillers.
Mission Tasks

Write a program that calculates the charges for an out-patient at the clinic. The program should:

Accept and validate: patient demographics: Ask for the patient's first and last name and employee ID number. The employee ID number is a 9-digit number given by Joe to all his workers. Employee ID numbers may begin with upto 5 zeros so they cannot be treated as integers since those zeros are important.

Accept and validate list of patient injuries: Display the list of injuries and have the nurse enter which injuries the miner sustained. You will need to loop since most accidents result in multiple injuries to the miners. Validate that all entries are on the list of treatable injuries. Since we do not know ahead of time how many injuries the miner will have, you should use a vector or an array to hold the list of injuries. (Note: If a miner has multiple injuries of the same type, the nurse will enter the injury type multiple times. For example, a broken arm and a broken leg would result in two "1st degree fractures" entries.)

Compute total cost of out-patient services: Add up the cost to treat all the injuries. If the patient had more than 5 injuries, give Joe's a 10% discount. After computing the discount, add in the cost of painkillers.

Display a bill that can be sent to Joe's insurance provider: The bill should have the patient's name and employee ID number, a list of injuries with the cost for each injury, any discounts and medications. The total cost should be displayed at the end. Your score depends on how nicely formatted and readable the bill is.

The program only needs to handle a single miner. It does not need to repeat (loop) and process additional miners.

My code so far, any thoughts?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #include <iostream>
#include <vector>
using namespace std;

int main()
{
	vector<int> injury(9)

		injury[painKillers] = 0;
		injury[severeAbrasionsAndBruising] = 0;
		injury[CutsStiches] = 0;
		injury[firstDegreeFractures] = 0;
		injury[secondDegreeFractures] = 0;
		injury[burnTreatment] = 0;
		injury[severedAppendages] = 0; //fingers/toes
		injury[SecseveredAppendages] = 0; //legs/arms
		injury[concussion] = 0;

	cout << "Please enter the patient's first and last name: ";
	int name;
	 cin >>  name;
	cout << "Please enter employee ID: ";
	double id;
	cin >> id;
Last edited on
1
2
cout << "Please enter the patient's first and last name: ";
int name;

I think you might wanna replace that int either with a string or a char array.

if you do choose to use string, then replace cin >> name; with getline(cin, name); else, it'll only read until first whitespace.
Last edited on
Thanks, I made some changes and this is what i have now so far

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
	#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	vector<string> injuries(8);
	vector<int> primes(8);

	string name;
	double employeeId;
	double numberOfInjuries = 0.0;
	int cases = 0;
	int sumOfprices = 0;
	

		injuries[0] = "Severe Abrasions and Bruising";
		injuries[1] = "Cuts w/Stiches";
		injuries[2] = "1st Degree Fractures";
		injuries[3] = "2nd Degree Fractures";
		injuries[4] = "Burn Treatment (all degrees)";
		injuries[5] = "Severed Appendage (Fingers/Toes)";
		injuries[6] = " Severed Appendages (Arms/Legs)";
		injuries[7] = "Concussion";


		primes[0] = 20;
		primes[1] = 60;
		primes[2] = 150;
		primes[3] = 350;
		primes[4] = 200;
		primes[5] = 180;
		primes[6] = 430;
		primes[7] = 45;

	cout << "Please enter the patient's first and last name: ";
	getline(cin, name);
	cout << "Please enter employee ID: ";
	cin >> employeeId;

	while (cases != 8) 
	{
	cout << injuries[0] << "\t - Type '0' " << endl;
	cout << injuries[1] << "\t - Type '1' " << endl;
	cout << injuries[2] << "\t - Type '2' " << endl;
	cout << injuries[3] << "\t - Type '3' " << endl;
	cout << injuries[4] << "\t - Type '4' " << endl;
	cout << injuries[5] << "\t - Type '5' " << endl;
	cout << injuries[6] << "\t - Type '6' " << endl;
	cout << injuries[7] << "\t - Type '7' " << endl;
	cout << "No other injuries" << "\t - Type '8' " << endl;
	cin >> cases;

	if (cases > 8 || cases < 0)
	{
	cout << "Enter a valid number!" << endl; 
	cout << injuries[0] << "\t - Type '0' " << endl;
	cout << injuries[1] << "\t - Type '1' " << endl;
	cout << injuries[2] << "\t - Type '2' " << endl;
	cout << injuries[3] << "\t - Type '3' " << endl;
	cout << injuries[4] << "\t - Type '4' " << endl;
	cout << injuries[5] << "\t - Type '5' " << endl;
	cout << injuries[6] << "\t - Type '6' " << endl;
	cout << injuries[7] << "\t - Type '7' " << endl;
	cout << "No other injuries" << "\t - Type '8' " << endl;
	cin >> cases;
	}
	sumOfprices = sumOfprices + primes[cases];
}
	
	cout << sumOfprices << endl;
	cin.sync();
    getchar();
    return 0;
}
Last edited on
Topic archived. No new replies allowed.