#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; }
#include <iostream> #include <cmath> using namespace std; int main() ;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; }
#include <iostream> #include <cmath> using namespace std; int main() ;float RPar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix; int 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; }
int main()
;float RPar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix;
int quantity;
{int main()
{
float Rpar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix;
int quantity;case '2':
case 2:
#include <iostream> #include <cmath> using namespace std; int main() float Rpar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix; int 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
int main()
{ // the opening brace of main
This:should be like this:int main() ;float RPar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix; int quantity; {int main() { float Rpar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix; int quantity;
#include <iostream> #include <cmath> using namespace std; int main() { float Rpar, Rone, Rtwo, Rthree, Rfour, Rfive, Rsix; int 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; } Compiling... ResistancePar.cpp G:\VC++60\ResistancePar\ResistancePar.cpp(21) : error C2043: illegal break G:\VC++60\ResistancePar\ResistancePar.cpp(22) : error C2046: illegal case G:\VC++60\ResistancePar\ResistancePar.cpp(29) : error C2043: illegal break G:\VC++60\ResistancePar\ResistancePar.cpp(30) : error C2046: illegal case G:\VC++60\ResistancePar\ResistancePar.cpp(39) : error C2043: illegal break G:\VC++60\ResistancePar\ResistancePar.cpp(40) : error C2046: illegal case G:\VC++60\ResistancePar\ResistancePar.cpp(51) : error C2043: illegal break G:\VC++60\ResistancePar\ResistancePar.cpp(52) : error C2046: illegal case G:\VC++60\ResistancePar\ResistancePar.cpp(65) : error C2043: illegal break G:\VC++60\ResistancePar\ResistancePar.cpp(66) : error C2046: illegal case Error executing cl.exe. ResistancePar.obj - 10 error(s), 0 warning(s)
| DaniWeb Message | |
| Cancel Changes | |