I am trying to write a program that generates a table of temperature conversions
ID: 3528765 • Letter: I
Question
I am trying to write a program that generates a table of temperature conversions. I am very new to C++ and I really need some help. I do know that there is error in my code and it will not compile. I haven't learned how to read the errors (and google hasn't helped) that command prompt alerts you to when compiling fails. So as you can imagine it's very hard to correct my errors, and I'm not even sure the code I have used will properly generate a table. Please help! Errors displayed by command prompt: other.cpp: In function" int main<>': other.cpp:34:10:error: expected primary-expression before '=' token Code: #include #include #include #include #includeusing namespace std; int main() { double USD; double PESO; double RAND; double YEN; PESO=9.02; // rate = dollar per peso RAND=0.01; YEN=11.30; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << setw(10) << "Dollars" << setw(10) << "Pesos" << setw(10) << "rand" << setw(10) << "YEN" << setw(10) <<endl; for(USD = 0.0; USD <= 50.0; USD += 1.0) { cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; } for(PESO = 0.0; PESO <= 50.0; PESO += 1.0) { cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; } for(RAND = 0.0; RAND <= 50.0; RAND += 1.0) { cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; } for( = 0.0; YEN <= 50.0; YEN += 1.0) { cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; } system("PAUSE"); return 0; }Explanation / Answer
/** here is the corrected code...include all your header files***/
using namespace std;
int main() {
double USD; double PESO; double RAND; double YEN;
PESO=9.02; // rate = dollar per peso
RAND=0.01;
YEN=11.30;
cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2);
cout << setw(10) << "Dollars" << setw(10) << "Pesos" << setw(10) << "rand" << setw(10) << "YEN" << setw(10) <<endl;
for(USD = 0.0; USD <= 50.0; USD += 1.0) {
cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; }
for(PESO = 0.0; PESO <= 50.0; PESO += 1.0) {
cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; }
for(RAND = 0.0; RAND <= 50.0; RAND += 1.0) {
cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; }
for( YEN= 0.0; YEN <= 50.0; YEN += 1.0) {
cout << setw(10) << USD*PESO << setw(10) << USD*RAND << setw(10) << USD* YEN << endl; }
system("PAUSE");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.