View Single Post
 09-02-2012, 12:48 AM PM User | #1 kawaiiresachan New to the CF scene   Join Date: Sep 2012 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts Help with Scientific Notation in Java 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"); } }``` Last edited by VIPStephan; 09-02-2012 at 01:08 AM.. Reason: fixed code BB tags