if else loops
Nov 16, 2016 at 10:30pm UTC
So, I know some of the rest of the code is probably wrong, but my current issue is that whenever i compile it returns:
"expected primary-expression before 'else'"
"expected `;' before 'else'"
for all loops containing else if expressions. Is there something I'm missing within the expressions or is some other part of my code messing them up?
Thanks for any help!
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
/*Problem 2--Sutures*/
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
double BatchNumber, Temperature, Pressure, DwellTime;
ifstream infile;
infile.open ("Sutures.txt" );
infile >> BatchNumber >> Temperature >> Pressure >> DwellTime;
double T, P, D, Total, Rejected, Name;
cout << "Enter team name(s): " << endl;
cin >> Name;
cout << "Enter total number of batches: " << endl;
cin >> Total;
T = Total;
P = Total;
D = Total;
Rejected = Total;
while (infile) {
if (150 <= Temperature <= 170) {
T = T--;
Rejected = Rejected--;
}
if (60 <= Pressure <= 70) {
P = P--;
else if (150 <= Temperature <= 170) {
Rejected = Rejected;
}
else {
Rejected = Rejected--;
}
}
if (2 <= DwellTime <= 2.5) {
D = D--;
else if (150 <= Temperature <= 170) {
Rejected = Rejected;
}
else if (2 <= DwellTime <= 2.5); {
Rejected = Rejected;
}
else {
Rejected = Rejected-1;
}
}
}
double Tfail, Pfail, Dfail;
Tfail = (T/Total)*100;
Pfail = (P/Total)*100;
Dfail = (D/Total)*100;
cout << "Team Name: " << Name << endl;
cout << " Percent Failures Total | Rejected" << endl;
cout << "Temp |" << Tfail << " " << Total << " " << Rejected << endl;
cout << "Pressure |" << Pfail << endl;
cout << "Dwell Time |" << Dfail << endl;
system ("pause" );
return 0;
}
Nov 17, 2016 at 12:01am UTC
Topic archived. No new replies allowed.