mayorredbeard
Daemon Poster
- Messages
- 1,246
My code so far:
--------------------------------------------------------------------------
#include <iostream>
#include <conio.h>
#include <math.h>
//declare variables
using std::cin;
using std::cout;
int main()
{
double rateOne, rateTwo, mOne, mTwo;
cout << "Enter rate one: ";
cin >> rateOne;
cout << "Enter rate two: ";
cin >> rateTwo;
cout << "Enter 'm' one: ";
cin >> mOne;
cout << "Enter 'm' two: ";
cin >> mTwo;
//Peform calculations
double calculatedRate = rateOne * rateTwo;
double dividedM = mTwo * mOne;
double calculatedM = sqrt(dividedM);
cout << calculatedM << "=" << calculatedRate;
getche();
return 0;
}
--------------------------------------------------------------------------
Alright, so what this program does is it allows me to enter in four variables. It's basically the first of many programs to allow me to do some of my chem homework, (even though this is so much harder then just doing it, hehe). Anyways i've only recently gotten into C++ programming, and for that matter programming at all. What I want to be able to do is enter in a variable for rateOne, rateTwo, mOne, or mTwo, and then solve for the variable. But it doesn't work, obviously. How could I rewrite this code to allow me to do it. I don't want someone to edit it for me and give me the code, I want someone to tell me what I need to learn to do this myself.
--------------------------------------------------------------------------
#include <iostream>
#include <conio.h>
#include <math.h>
//declare variables
using std::cin;
using std::cout;
int main()
{
double rateOne, rateTwo, mOne, mTwo;
cout << "Enter rate one: ";
cin >> rateOne;
cout << "Enter rate two: ";
cin >> rateTwo;
cout << "Enter 'm' one: ";
cin >> mOne;
cout << "Enter 'm' two: ";
cin >> mTwo;
//Peform calculations
double calculatedRate = rateOne * rateTwo;
double dividedM = mTwo * mOne;
double calculatedM = sqrt(dividedM);
cout << calculatedM << "=" << calculatedRate;
getche();
return 0;
}
--------------------------------------------------------------------------
Alright, so what this program does is it allows me to enter in four variables. It's basically the first of many programs to allow me to do some of my chem homework, (even though this is so much harder then just doing it, hehe). Anyways i've only recently gotten into C++ programming, and for that matter programming at all. What I want to be able to do is enter in a variable for rateOne, rateTwo, mOne, or mTwo, and then solve for the variable. But it doesn't work, obviously. How could I rewrite this code to allow me to do it. I don't want someone to edit it for me and give me the code, I want someone to tell me what I need to learn to do this myself.