Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The problem states: Make the earth move up by 0.5 units each time the while loop

ID: 3614084 • Letter: T

Question

The problem states:
Make the earth move up by 0.5 units each time the while loopexecutes.
When it reaches the top of the "universe", make it reappear at thebottom of the universe.
I am having problems with the if statement that makes the earthappear at the bottom of the screen.
Here is the code I have so far:

public class Planets0 {
    public static void main(String[] args) {
      
        System.out.print("Enterthe radius of the universe: ");
        double radius =StdIn.readDouble();
      
       StdDraw.setXscale(-radius, radius); // rescale coordinates
       StdDraw.setYscale(-radius, radius);
        StdDraw.picture(0, 0,"earth.gif");
               
        // set initialposition
        double xpos = 0.0;
        double ypos = 0.0;
        double yvel = .43;
        while (true) { // loopforever or until program closed
           ypos = yvel + ypos;
           
           StdDraw.clear(StdDraw.WHITE);
           StdDraw.picture(xpos, ypos , "earth.gif"); // draw the ball
           StdDraw.show(50);
        }
      
    }
}

Explanation / Answer

please rate - thanks not knowing anything about these methods was very difficult, Ifinally found the draw but changed your input to standardjava import java.util.*; public class Planets0 {     public static void main(String[] args) {         Scanner StdIn=new Scanner(System.in);         System.out.print("Enterthe radius of the universe: ");         doubleradius = StdIn.nextDouble();               StdDraw.setXscale(-radius, radius); // rescale coordinates        StdDraw.setYscale(-radius, radius);         StdDraw.picture(0, 0,"earth.gif");                         // set initialposition         double xpos = 0.0;         double ypos = 0.0;         double yvel = .43;         while (true) { // loopforever or until program closed            ypos = yvel + ypos;            if(ypos>=50)        /*play with the 50 I didn't know how large the window was, shouldbe based on top window value and diameter of moon   I ranwith radius 20 */                        ypos=-50;            StdDraw.clear(StdDraw.WHITE);            StdDraw.picture(xpos, ypos , "earth.gif"); // draw the ball               StdDraw.show(50);        }            } }