Error code C1075

I cannot seem to locate the problem in my code. I constantly get the error "fatal error C1075: end of file found before the left brace '{'" and it refers to line 90.

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
 // Header files section
#include <iostream>
using namespace std;
// Function prototypes

double getTotalCharges(int, double, double, double);

double getTotalCharges(double, double);

// start main function

int main()
{
	//Declare variables

	int typeOfPatient, numberOfDays;

	double dailyRate, medicationCharges, serviceCharges;
	double totalCharges;

	// Prompt the user for type of patient
	
	cout << "Enter the type of patient (1 for in-patient or 2 for out-patient): ";

	cin >> typeOfPatient;

	// Verify whether the type of patient is valid

	while(typeOfPatient != 1 && typeOfPatient != 2)
	{
		cout << "Enter the type of patient (1 for in-patient or 2 for out-patient): ";
		cin >> typeOfPatient;
	} // end while statement
	//Prompt the user for hospital medication charges
	cout << "Enter the hospital medication charges: ";
	cin >> medicationCharges;
	/* Verify whether the hospital medication charges are negative */
	while(medicationCharges < 0)
	{
		cout << "Enter the hospital medication charges: ";
		cin >> medicationCharges;

	/* Verify whether the hospital medication charges are negative */
		while(medicationCharges < 0)
		{
			cout << "Enter the hospital medication charges: ";
			cin >> medicationCharges;
		} //end while
		//prompt the user for hospital service charges
		cout << "Enter the hospital service charges: ";
		cin >> serviceCharges;
		/* Verify whether the hospital service charges are negative */
		while(serviceCharges < 0)
		{
			cout << "Enter the hospital service charges: ";
			cin >> serviceCharges;
		} //end while
		//Verify whether the type of patient is in-patient
		if(typeOfPatient==1)
		{
		/* Prompt the user for number of days patient spent */
		cout << "Enter the number of days spent by patient in the hospital:";
		cin >> numberOfDays;
		//Verify whether the number of days is negative
		while(numberOfDays < 0)
		{
		cout << "Enter the number of days spent by patient in the hospital:";\
		cin>>numberOfDays;
		} // end while
		// Prompt the user for daily rate
		cout << "Enter the daily rate in the hosptal:";
		cin >>dailyRate;
		//Verify whether the daily rate is negative
		while(dailyRate < 0)
		{
			cout << "Enter the daily rate in the hospital: ";
			cin >> dailyRate;
		} // endwhile
		// Get the total charges
		totalCharges = getTotalCharges(numberOfDays, dailyRate, medicationCharges, serviceCharges);
		}
		else // if the type of patient is out-patient
			totalCharges = getTotalCharges(medicationCharges, serviceCharges);
		// Display the total hospital charges
		cout << "The hospital charges for the patient are: $" << totalCharges << endl;
		// pause the system for a while
		system("pause");
		return 0;
	} // end of main function
I think your missing a right brace between line 63 and 64.
@alonso12
That yielded the same error, and also caused "error c2181: illegal else without matching if."
Last edited on
Finding a missing brace in such a long main function is difficult. It's much better practice to divide your program into functions, they make the whole code easier to read.
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
// Header files section
#include <iostream>

using namespace std;

double getTotalCharges(int numberOfDays, double dailyRate, 
                       double medicationCharges, double serviceCharges)
{
  return numberOfDays * dailyRate + medicationCharges + serviceCharges;
}

double getTotalCharges(double medicationCharges, double serviceCharges)
{
  return medicationCharges + serviceCharges; 
}

int getPatientType()
{
  int typeOfPatient;
  cout << "Enter the type of patient (1 for in-patient or 2 for out-patient): ";
  cin >> typeOfPatient;

  // Verify whether the type of patient is valid

  while (typeOfPatient != 1 && typeOfPatient != 2)
  {
    cout << "Enter the type of patient (1 for in-patient or 2 for out-patient): ";
    cin >> typeOfPatient;
  } // end while statement

  return typeOfPatient;
}

double getMedicationCharges()
{
  double medicationCharges;
  cout << "Enter the hospital medication charges: ";
  cin >> medicationCharges;
  /* Verify whether the hospital medication charges are negative */
  while (medicationCharges < 0)
  {
    cout << "Enter the hospital medication charges: ";
    cin >> medicationCharges;

  }
  return medicationCharges;
}

double getServiceCharges()
{
  double serviceCharges;
  cout << "Enter the hospital service charges: ";
  cin >> serviceCharges;
  /* Verify whether the hospital service charges are negative */
  while (serviceCharges < 0)
  {
    cout << "Enter the hospital service charges: ";
    cin >> serviceCharges;
  } //end while

  return serviceCharges;
}

int getNumberOfDays()
{
  int numberOfDays;
  /* Prompt the user for number of days patient spent */
  cout << "Enter the number of days spent by patient in the hospital:";
  cin >> numberOfDays;
  //Verify whether the number of days is negative
  while (numberOfDays < 0)
  {
    cout << "Enter the number of days spent by patient in the hospital:"; \
      cin >> numberOfDays;
  } // end while

  return numberOfDays;
}

double getDailyRate()
{
  double dailyRate;
  cout << "Enter the daily rate in the hosptal:";
  cin >> dailyRate;
  //Verify whether the daily rate is negative
  while (dailyRate < 0)
  {
    cout << "Enter the daily rate in the hospital: ";
    cin >> dailyRate;
  } // endwhile
  
  return dailyRate;
}

int main()
{
  double totalCharges;
  int typeOfPatient = getPatientType();
  double medicationCharges = getMedicationCharges();
  double serviceCharges = getServiceCharges();
  //Verify whether the type of patient is in-patient
  if (typeOfPatient == 1)
  {
    int numberOfDays = getNumberOfDays();
    double dailyRate = getDailyRate();
    totalCharges = getTotalCharges(numberOfDays, dailyRate, 
                          medicationCharges, serviceCharges);
  }
  else // if the type of patient is out-patient
  {
    totalCharges = getTotalCharges(medicationCharges, 
                                   serviceCharges);
  }
  // Display the total hospital charges
  cout << "The hospital charges for the patient are: $" << totalCharges << endl;
  // pause the system for a while
  system("pause");
  return 0;
} // end of main function 
Thank you so much.
Topic archived. No new replies allowed.