#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { char Operation(); string variableStr; double V1; double V2; double T1; double T2; cout << "V1/T1 = V2/T2" << endl << "Which variable are you solving for?" << endl; cin >> variableStr; system("clear"); if (variableStr == "V1") { cout << "What is the value of T1 in Kelvin?" << endl; cin >> T1; cout << "What is the value of V2?" << endl; cin >> V2; cout << "What is the value of T2 in Kelvin?" << endl; cin >> T2; V1 = (V2/T2)*T1; return V1; } else if (variableStr == "V2") { cout << "What is the value of T1 in Kelvin?" << endl; cin >> T1; cout << "What is the value of T2 in Kelvin?" << endl; cin >> T2; cout << "What is the value of V1?" << endl; cin >> V1; V2 = (V1/T1)*T2; return V2; } else if (variableStr == "T1") { cout << "What is the value of T2 in Kelvin?" << endl; cin >> T2; cout << "What is the value of V1?" << endl; cin >> V1; cout << "What is the value of V2?" << endl; cin >> V2; T1 = V1/(V2/T2); return T1; } else if (variableStr == "T2") { cout << "What is the value of T1 in Kelvin?" << endl; cin >> T1; cout << "What is the value of V1?" << endl; cin >> V1; cout << "What is the value of V2?" << endl; cin >> V2; T2 = V2/(V1/T1); return T2; } else { cout << "Please enter a valid option!" << endl; char Operation(); } return 0; }
Python
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)