Hello all :p
I was working on this simple program with a formula for
calculating parallel resistance. I was getting all kinds
of errors at first but I am still getting these few.
Compiling...
ResistancePar.cpp
G:\VC++60\ResistancePar\ResistancePar.cpp(5) : warning C4518: 'float ' : storage-class or type specifier(s) unexpected here; ignored
G:\VC++60\ResistancePar\ResistancePar.cpp(5) : error C2146: syntax error : missing ';' before identifier 'RPar'
G:\VC++60\ResistancePar\ResistancePar.cpp(5) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
ResistancePar.obj - 2 error(s), 1 warning(s)
#include <iostream>
using namespace std;
int main (void)
float RPar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix;
{
char quantity;
cout << "Enter the quantity of resistors" << endl;
cout << "A maximum of 6 resistors please" << endl;
cin >> quantity;
switch (quantity)
{
case '1':
cout << " You must enter at least 2";
break;
case '2':
cout << " Enter the value of the first resistor";
cin >> Rone;
cout << " Enter the value of the second resistor";
cin >> "Rtwo;
Rpar = (Rone * Rtwo) / (Rone + Rtwo);
cout <<"The value of parallel resistance is: " << Rpar << "\n";
break;
case '3':
cout << " Enter the value of the first resistor";
cin >> Rone;
cout << " Enter the value of the second resistor";
cin >> "Rtwo;
cout << " Enter the value of the third resistor";
cin >> "Rthree;
Rpar = (Rone * Rtwo * Rthree) / (Rone + Rtwo + Rthree);
cout <<"The value of parallel resistance is: " << Rpar << "\n";
break;
case '4':
cout << " Enter the value of the first resistor";
cin >> Rone;
cout << " Enter the value of the second resistor";
cin >> "Rtwo;
cout << " Enter the value of the third resistor";
cin >> "Rthree;
cout << " Enter the value of the fouth resistor";
cin >> "Rfour;
Rpar = (Rone * Rtwo * Rthree * Rfour) / (Rone + Rtwo + Rthree + Rfour);
cout <<"The value of parallel resistance is: " << Rpar << "\n";
break;
case '5':
cout << " Enter the value of the first resistor";
cin >> Rone;
cout << " Enter the value of the second resistor";
cin >> "Rtwo;
cout << " Enter the value of the third resistor";
cin >> "Rthree;
cout << " Enter the value of the fouth resistor";
cin >> "Rfour;
cout << " Enter the value of the fifth resistor";
cin >> "Rfive;
Rpar = (Rone * Rtwo * Rthree * Rfour * Rfive) / (Rone + Rtwo + Rthree + Rfour + Rfive);
cout <<"The value of parallel resistance is: " << Rpar << "\n";
break;
case '6':
cout << " Enter the value of the first resistor";
cin >> Rone;
cout << " Enter the value of the second resistor";
cin >> "Rtwo;
cout << " Enter the value of the third resistor";
cin >> "Rthree;
cout << " Enter the value of the fouth resistor";
cin >> "Rfour;
cout << " Enter the value of the fifth resistor";
cin >> "Rfive;
cout << " Enter the value of the sixth resistor";
cin >> "Rsix;
Rpar = (Rone * Rtwo * Rthree * Rfour * Rfive * Rsix) / (Rone + Rtwo + Rthree + Rfour + Rfive + Rsix);
cout <<"The value of parallel resistance is: " << Rpar << "\n";
}
return 0;
}
Any help would be appreciated.
Thanks, BandM