Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago