Hi, I am a college freshman and I am taking my very first Java programming class. I have never programmed before, so I am having a little bit of trouble. For our second lab, we are to put numbers into scientific notation using the mod (%) and printf operator. I am having trouble doing this, so could some body help me figue out what I need to do? Here is a copy of my code:
Code:
import java.util.Scanner;
public class UniversalGravitation {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double m1;
double m2;
double r;
double a1;
double a2;
final double G = 6.67384e-11;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the mass of the first object (in kilograms) ");
m1 = keyboard.nextDouble();
System.out.print("Enter the mass of the second object (in kilograms) ");
m2 = keyboard.nextDouble();
System.out.print("Enter the dsitance (in meters) between them ");
r = keyboard.nextDouble();
double F = G * ((m1*m2)/Math.pow(r, 2));
a1 = F/m1;
a2 = F/m2;
System.out.printf("Mass of first object: \t\t" + m1 + "kg");
System.out.println("Mass of second object: \t\t" + m2 + " kg");
System.out.println("Distance: \t\t\t" + r + " m");
System.out.println("Force: \t\t\t\t" + F + "N");
System.out.println("Acc. of first object: \t\t" + a1 + "m/s^2");
System.out.println("Acc. of second object: \t\t" + a2 + " m/s^2");
}
}