Orbiting Planets And Moons

May 4, 2014

I'm trying to make a code that has several orbiting images, a moon orbiting the earth, and then a smaller moon orbiting the moon. Getting the main moon orbiting the earth wasn't too difficult, it just requires rotating the moon image around the center of the earth. However, how to get the smaller moon rotating around the big one. How to do this? The images I'm using are attached.

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JFrame;

[Code] .....

Moon.jpgoie_transparent.jpgRocket.jpgGalaxy2.jpg

View Replies


ADVERTISEMENT

Method From Main - Calculate Weight On Different Planets

Nov 8, 2014

I have to write a program to calculate my weight on different planets and to do that, I have to read in the surface gravity of all the planets from a file using a separate method from main

public static double[] readGravity() throws IOException
{
double[] surfaceGravity = new double[8];
Scanner readFile = new Scanner("gravity1.txt");
int i = 0;
while (readFile.hasNext()) {
surfaceGravity[i] = readFile.nextDouble();
i++;
}
return surfaceGravity;
}

I get this message in the while loop when I try to run the program:

java.util.InputMismatchException;
null (in java.util.Scanner)

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved