Question

In: Computer Science

Using newtons gravitation laws, design a program in C++ that determine the position of n=3 number...

Using newtons gravitation laws, design a program in C++ that determine the position of n=3 number of bodies relative to each other, and outputs the results in a ongoing table that constantly updates as long as the simulation runs, and a pgPlot.

Implement the newtonian equations using the LEAPFROG Method. Show how the you solved the equations.
Make sure to describe each section of your code to describe what each part of your code is responsible for (i.e use //) to recieve full marks?

Solutions

Expert Solution

Code:

#include <iostream>
#include<math.h>
using namespace std;

float LEAPFROG(float m1,float m2, float r){//pass the mass of two objects and r=seperation in meters
float g = 6.67*pow(10.0,-11.0);//Universal Gravitational Constant = 6.67*10^-11 N-m^2/kg^2
double f = (g*m1*m2)/(r*r);//Gravitation force of attraction between two objects in newton(N)
return f;
}
int main()
{
float m1,m2,r;
double f;
cout<<"Enter the value of two masses in Kg : "<<endl;
cin>>m1>>m2;
cout<<"Enter the distance between two masses in meters : "<<endl;
cin>>r;
f=LEAPFROG(m1,m2,r);//call the function
cout<<"The force of attraction between two masses = "<<f<<" Newton ";
return 0;
}

Note:****I hope your happy with my answer****If you have any doubt please comment me*****Thank you.......


Related Solutions

Write a program in C or C++ that takes a number series of size n (n...
Write a program in C or C++ that takes a number series of size n (n integers) as input from the user, push all the numbers to the stack, and reverse the stack using recursion. Please note that this is not simply popping and printing the numbers, but the program should manipulate the stack to have the numbers stored in reverse order. In addition to the provided header file, the students can use the following function to print the content...
Using pseudocode design a number guessing game program. The program should generate a random number and...
Using pseudocode design a number guessing game program. The program should generate a random number and then ask the user to guess the number. Each time the user enters his or her guess, the program should indicate it was too high or too low. The game is over when the user correctly guesses the number. When the game ends, the program should display the number of guesses that the user made.
Prove using mathematical induction: 3.If n is a counting number then 6 divides n^3 - n....
Prove using mathematical induction: 3.If n is a counting number then 6 divides n^3 - n. 4.The sum of any three consecutive perfect cubes is divisible by 9. 5.The sum of the first n perfect squares is: n(n +1)(2n +1)/ 6
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
Write a program to reverse each integer number on array (size 3) using while loop. C++...
Write a program to reverse each integer number on array (size 3) using while loop. C++ Input: 3678 2390 1783 Output: 8763 0932 3871
A powerful contribution of the 1st and 2nd laws is to determine the design feasibility of...
A powerful contribution of the 1st and 2nd laws is to determine the design feasibility of a process/device/system. Please determine the feasibility of the following flow device: a steady-state flow device in which the inlet is steam at 300and 5 bar, the outlet is saturated steam at 100 and 1 bar, the device is adiabatic and produces approximately 500 kJ per kilogram of steam passed through the device.
Program is to be written in C++ using Visual studios Community You are to design a...
Program is to be written in C++ using Visual studios Community You are to design a system to keep track of either a CD or DVD/Blu-ray collection. The program will only work exclusively with either CDs or DVDs/Blu-rays since some of the data is different. Which item your program will work with will be up to you. Each CD/DVD/Blu-ray in the collection will be represented as a class, so there will be one class that is the CD/DVD/Blu-ray. The CD...
Using C language, and describe the algorithm design Q2 Problem description n (n is odd) people...
Using C language, and describe the algorithm design Q2 Problem description n (n is odd) people sitting around a round table playing a game. In this situation, everyone has a left neighbour and a right neighbour. At the beginning, each of them is holding a whiteboard with an integer number. Now, they are playing a game consisting of several rounds. In each round, everyone will first look at the numbers of his/her left neighbour and right neighbour, then calculate the...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and amount spent in the store last month. Display the data only if the customer is a high spender – a person who spent more than $1000 in the store. A program that accepts customer info continuously until a sentinel value is entered and displays a list of high spenders.
Please answer using MSP design and program for C. Write CCS code. outline the program for...
Please answer using MSP design and program for C. Write CCS code. outline the program for MSP design, and program for C. Make a project that uses one timer on the board to control the blinking of the LED. Basically setup a timer interupt. Whenever the timer interrupt happens, the LED blinks. The frequency of the blinking is chosen by the user. Next modify the program above and make a project that uses one of the pushbuttons on the board...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT