Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // DailyProgrammerChallenge138InCPP.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- // Variable declaration
- float mass1;
- float mass2;
- float x1;
- float x2;
- float y1;
- float y2;
- float deltaX;
- float deltaY;
- float distance;
- float force;
- // Variable input for particle 1
- cout << "Mass of particle 1" << endl;
- cin >> mass1;
- cout << "X-position of particle 1" << endl;
- cin >> x1;
- cout << "Y-position of particle 1" << endl;
- cin >> y1;
- // Variable input for particle 2
- cout << "Mass of particle 2" << endl;
- cin >> mass2;
- cout << "X-position of particle 2" << endl;
- cin >> x2;
- cout << "Y-position of particle 2" << endl;
- cin >> y2;
- // Calculations
- deltaX = (x1 - x2);
- deltaY = (y1 - y2);
- distance = sqrt((deltaX * deltaX) + (deltaY * deltaY));
- force = ((mass1 * mass2) / (distance * distance));
- cout << "The repulsion force between the two particles is " << force << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement