Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.Math;
- import java.util.Scanner;
- public class Gravitation_Force{
- public static void main(String[]args){
- final double G = 6.67;
- final double P_K = 0.453592;
- //F = G*(m1*m2)/r^2
- System.out.println("Pounds(1) or Kilos(2)?");
- int input = Expo.enterInt();
- switch(input)
- {
- case(1): System.out.println("Pounds");
- System.out.println("Enter m1 and m2");
- double m1 = Expo.enterDouble();
- double m2 = Expo.enterDouble();
- double m1k = m1*P_K;
- double m2k = m1*P_K;
- System.out.println("Enter distance");
- double r = Expo.enterDouble();
- double a = (m1k*m2k)/r*r;
- double f = G*a;
- System.out.println("The gravitational attraction beetwenn mass 1 and mass 2 is " + f);
- break;
- case(2): System.out.println("Kilos");
- System.out.println("Enter m1 and m2");
- double k1 = Expo.enterDouble();
- double k2 = Expo.enterDouble();
- System.out.println("Enter distance");
- double r1 = Expo.enterDouble();
- double a1 = (k1*k2)/r1*r1;
- double f1 = G*a1;
- System.out.println("The gravitational attraction beetwenn mass 1 and mass 2 is " + f1);
- break;
- default: System.out.println("Non-Recognized");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement