Question
please explain every line and what it does import java.util.*; import java.io.*; import java.math.*; /** * Auto-generated code below aims at helping you parse *
please explain every line and what it does
import java.util.*; import java.io.*; import java.math.*;
/** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ class Player {
public static void main(String args[]) { int oldX=0; int oldY=0; double xFinal=0,yFinal=0; double Dx,Dy=0; Scanner in = new Scanner(System.in); int surfaceN = in.nextInt(); // the number of points used to draw the surface of Mars. for (int i = 0; i < surfaceN; i++) { int landX = in.nextInt(); // X coordinate of a surface point. (0 to 6999) int landY = in.nextInt(); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars. if (landY==oldY) { xFinal=(landX+oldX)*0.5; yFinal=landY; } else { oldX=landX; oldY=landY; } }
while (true) { int X = in.nextInt(); int Y = in.nextInt(); int hSpeed = in.nextInt(); // the horizontal speed (in m/s), can be negative. int vSpeed = in.nextInt(); // the vertical speed (in m/s), can be negative. int fuel = in.nextInt(); // the quantity of remaining fuel in liters. int rotate = in.nextInt(); // the rotation angle in degrees (-90 to 90). int power = in.nextInt(); // the thrust power (0 to 4).
// Write an action using System.out.println() // To debug: System.err.println("Debug messages..."); Dx=(xFinal-X)-(hSpeed*Math.abs(hSpeed)); Dy=(yFinal-Y)*2; rotate=(int)Math.toDegrees(Math.atan(Dx/Dy)); if(Math.abs(vSpeed)>30 || Math.abs(hSpeed)>20) { power=4; }else { power=3; } if(Dy>-200) { rotate=0; }
// rotate power. rotate is the desired rotation angle. power is the desired thrust power. System.out.println(rotate+" "+power); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started