Need help with finding the calculations for the pythagorean code, distance code,
ID: 3578315 • Letter: N
Question
Need help with finding the calculations for the pythagorean code, distance code, force code, mechanical advantage code, and momentum code
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
using namespace std;
int menu1, menu2, menu3;
float celsius, k = 273.15, kelvin; //celsius to kelvin and kelvin to celsius variables
float cm, miles, m = 160934.4; //cm to miles and miles to cm variables
float mph, kmh, p = 1.609344; //mph to kph and kph to mph variables
float lb, kg, g = 0.45359237; //lb to kg and kg to lb variables
float pt, gal, x = 8; //gallon to pint and pint to gallon
int main() {
while (menu1 != 3) {
label:
cout << "Select an Option" << endl;
cout << "-----------------" << endl;
cout << "1. Conversions" << endl;
cout << "2. Calculations" << endl;
cout << "3. Exit" << endl;
cin >> menu1;
while (menu2 != 11) {
switch (menu1) {
case 1:
cout << "Select an Option" << endl;
cout << "-----------------" << endl;
cout << "1. Celsius to Kelvin" << endl;
cout << "2. Kelvin to Celsius" << endl;
cout << "3. Cm to Miles" << endl;
cout << "4. Miles to Cm" << endl;
cout << "5. Mph to Kmh" << endl;
cout << "6. Kmh to Mph" << endl;
cout << "7. Pounds to Kilograms" << endl;
cout << "8. Kilograms to Pounds" << endl;
cout << "9. Pint to Gallon" << endl;
cout << "10. Gallon to Pint" << endl;
cout << "11. Go Back" << endl;
cin >> menu2;
switch (menu2) {
case 1:
cout << "Enter a Value for Celsius: ";
cin >> celsius;
_asm {
fld celsius;
fld k;
fadd;
fstp kelvin;
}
cout << celsius << " Celsius = " << kelvin << " Kelvin." << endl;
system("pause");
break;
case 2:
cout << "Enter a Value for Kelvin: ";
cin >> kelvin;
_asm {
fld kelvin;
fld k;
fsub;
fstp celsius;
}
cout << kelvin << " Kelvin = " << celsius << " Celsius." << endl;
system("pause");
break;
case 3:
cout << "Enter a Value for Cm: ";
cin >> cm;
_asm {
fld cm;
fld m;
fdiv;
fstp miles;
}
cout << cm << " Centimeters = " << miles << " Miles. " << endl;
system("pause");
break;
case 4:
cout << "Enter a Value for Miles: ";
cin >> miles;
_asm {
fld miles;
fld m;
fmul;
fstp cm;
}
cout << miles << " Miles = " << cm << " Centimeters. " << endl;
system("pause");
break;
case 5:
cout << "Enter a Value for Mph: ";
cin >> mph;
_asm {
fld mph;
fld p;
fmul;
fstp kmh;
}
cout << mph << " Mph = " << kmh << " Kmh. " << endl;
system("pause");
break;
case 6:
cout << "Enter a Value for Kmh: ";
cin >> kmh;
_asm {
fld kmh;
fld p;
fdiv;
fstp mph;
}
cout << kmh << " Kmh = " << mph << " Mph. " << endl;
system("pause");
break;
case 7:
cout << "Enter a Value for lb: ";
cin >> lb;
_asm {
fld lb;
fld g;
fmul;
fstp kg;
}
cout << lb << " lb = " << kg << " kg. " << endl;
system("pause");
break;
case 8:
cout << "Enter a Value for kg: ";
cin >> kg;
_asm {
fld kg;
fld g;
fdiv;
fstp lb;
}
cout << kg << " kg = " << lb << " lb. " << endl;
system("pause");
break;
case 9:
cout << "Enter a Value for Pint: ";
cin >> pt;
_asm {
fld pt;
fld x;
fdiv;
fstp gal;
}
cout << pt << " Pints = " << gal << " Gallons. " << endl;
system("pause");
break;
case 10:
cout << "Enter a Value for Gallons: ";
cin >> gal;
_asm {
fld gal;
fld x;
fmul;
fstp pt;
}
cout << gal << " Gallons = " << pt << " Pints. " << endl;
system("pause");
break;
default:
break;
}
break;
case 2:
cout << "Select an Option" << endl;
cout << "-----------------" << endl;
cout << "1. Pythagorean Theorem" << endl;
cout << "2. Distance" << endl;
cout << "3. Force" << endl;
cout << "4. Mechanical Advantage" << endl;
cout << "5. Momentum" << endl;
cout << "6. Go Back" << endl;
cin >> menu3;
switch (menu3) {
case 1:
cout << "test" << endl;//pythagorean code
system("pause");
break;
case 2:
cout << "test" << endl;//distance code
system("pause");
break;
case 3:
cout << "test" << endl;//force code
system("pause");
break;
case 4:
cout << "test" << endl;//mechanical advantage code
system("pause");
break;
case 5:
cout << "test" << endl;//momentum code
system("pause");
break;
default:
goto label;
}
default:
break;
}
}
}
}
Explanation / Answer
these are the eerrors you will get
prog.cpp: In function 'int main()':
prog.cpp:11:9: error: 'cout' was not declared in this scope
cout << "Select an Option" << endl;
^
prog.cpp:11:39: error: 'endl' was not declared in this scope
cout << "Select an Option" << endl;
^
prog.cpp:16:9: error: 'cin' was not declared in this scope
cin >> menu1;
^
prog.cpp:39:29: error: 'fld' was not declared in this scope
fld celsius;
^
prog.cpp:40:33: error: expected ';' before 'k'
fld k;
^
prog.cpp:41:29: error: 'fadd' was not declared in this scope
fadd;
^
prog.cpp:42:29: error: 'fstp' was not declared in this scope
fstp kelvin;
^
prog.cpp:45:39: error: 'system' was not declared in this scope
system("pause");
^
prog.cpp:51:29: error: 'fld' was not declared in this scope
fld kelvin;
^
prog.cpp:52:33: error: expected ';' before 'k'
fld k;
^
prog.cpp:53:29: error: 'fsub' was not declared in this scope
fsub;
^
prog.cpp:54:29: error: 'fstp' was not declared in this scope
fstp celsius;
^
prog.cpp:63:29: error: 'fld' was not declared in this scope
fld cm;
^
prog.cpp:64:33: error: expected ';' before 'm'
fld m;
^
prog.cpp:65:29: error: 'fdiv' was not declared in this scope
fdiv;
^
prog.cpp:66:29: error: 'fstp' was not declared in this scope
fstp miles;
^
prog.cpp:75:29: error: 'fld' was not declared in this scope
fld miles;
^
prog.cpp:76:33: error: expected ';' before 'm'
fld m;
^
prog.cpp:77:29: error: 'fmul' was not declared in this scope
fmul;
^
prog.cpp:78:29: error: 'fstp' was not declared in this scope
fstp cm;
^
prog.cpp:87:29: error: 'fld' was not declared in this scope
fld mph;
^
prog.cpp:88:33: error: expected ';' before 'p'
fld p;
^
prog.cpp:89:29: error: 'fmul' was not declared in this scope
fmul;
^
prog.cpp:90:29: error: 'fstp' was not declared in this scope
fstp kmh;
^
prog.cpp:99:29: error: 'fld' was not declared in this scope
fld kmh;
^
prog.cpp:100:33: error: expected ';' before 'p'
fld p;
^
prog.cpp:101:29: error: 'fdiv' was not declared in this scope
fdiv;
^
prog.cpp:102:29: error: 'fstp' was not declared in this scope
fstp mph;
^
prog.cpp:111:29: error: 'fld' was not declared in this scope
fld lb;
^
prog.cpp:112:33: error: expected ';' before 'g'
fld g;
^
prog.cpp:113:29: error: 'fmul' was not declared in this scope
fmul;
^
prog.cpp:114:29: error: 'fstp' was not declared in this scope
fstp kg;
^
prog.cpp:123:29: error: 'fld' was not declared in this scope
fld kg;
^
prog.cpp:124:33: error: expected ';' before 'g'
fld g;
^
prog.cpp:125:29: error: 'fdiv' was not declared in this scope
fdiv;
^
prog.cpp:126:29: error: 'fstp' was not declared in this scope
fstp lb;
^
prog.cpp:135:29: error: 'fld' was not declared in this scope
fld pt;
^
prog.cpp:136:33: error: expected ';' before 'x'
fld x;
^
prog.cpp:137:29: error: 'fdiv' was not declared in this scope
fdiv;
^
prog.cpp:138:29: error: 'fstp' was not declared in this scope
fstp gal;
^
prog.cpp:147:29: error: 'fld' was not declared in this scope
fld gal;
^
prog.cpp:148:33: error: expected ';' before 'x'
fld x;
^
prog.cpp:149:29: error: 'fmul' was not declared in this scope
fmul;
^
prog.cpp:150:29: error: 'fstp' was not declared in this scope
fstp pt;
^
prog.cpp:174:43: error: 'system' was not declared in this scope
system("pause");
^
Compilation error time: 0 memory: 0 signal:0
prog.cpp: In function 'int main()':
prog.cpp:39:25: error: '_asm' was not declared in this scope
_asm {
^
prog.cpp:46:39: error: 'system' was not declared in this scope
system("pause");
^
prog.cpp:51:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:63:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:75:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:87:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:99:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:111:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:123:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:135:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:147:30: error: expected ';' before '{' token
_asm {
^
prog.cpp:175:43: error: 'system' was not declared in this scope
system("pause");
^
in order to run and complle the code with out errors
we need to define each and everything in side a single function or we need to define and initilize each and everthing