Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried to make a program for calculating the mass of an orbiting body- but Its pretty much totaled. If someone could sort this mess out I will be eternally thankful. Here's the code, good luck.

C++
#include <iostream>
int main()
using namespace std;{


int main ()
{
	system("pause");
	int i;
	cout <<"Input orbital period in seconds: ";
	cin >> t;
	cout << "Orbital time= " << t;
	cout << "Input Object distance from sun in meters: ";
	(cin >> d;
	cout << "Orbital distance= " << d;
	
	g = (6.6 * 10^-11)

	m = (d^3 * (4 * 3.14159)^2) / (g * (t^2))

	cout << "Object mass= " << m;

	

}</iostream>
Posted
Updated 31-Aug-15 2:36am
v4
Comments
Patrice T 29-Aug-15 20:31pm    
What is your problem exactly ?
Sergey Alexandrovich Kryukov 29-Aug-15 21:03pm    
Sorry, this is not a question; it's a request: "do my job for me", without even exact specifications of requirements.
—SA
Patrice T 29-Aug-15 21:35pm    
I see that it is also a repost with only 1 line change.
http://www.codeproject.com/Questions/1022787/How-do-I-get-a-program-to-pause

Please see my comment to the question (rather a non-question).

No, this is not a "broken program", this is a program which never has been written, so there is nothing to break. And, I guess, you never learned the language you pretend to write in. For example, you need to declare all variables, use the type double for your calculations, to calculate power, you have to use the function pow (http://www.cplusplus.com/reference/cmath/pow[^]), and so on.

No, you need no help except a good kick: sit down and learn the subject, to learn how to do the job.

—SA
 
Share this answer
 
In C/C++ as in many other programming language ^ denote the XOR operator and not an exponent.

So what you have written as 6.6 * 10^-11 should be written as 6.6e-11. The same apply for Pow in formula. For a power of two, one would usually write something like (t * t) since it is more efficiency and quite common. For other function, one would generally use pow function from the standard library.
 
Share this answer
 
Your solution: Learn the language

You are actually asking us to do the program for you incrementally by Reposting the same program every time you make a change.
How do I get a program to pause?[^]

That is Abusive
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900