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

Java this is my incomplete code QUESTION 4: Write a class named Robot that takes

ID: 3783746 • Letter: J

Question

Java

this is my incomplete code

QUESTION 4: Write a class named Robot that takes a point (xy to represent a robot's initial location (in centimeters) as well as its orientation (an angle called theta which is a value between 0 and 360 degrees. You can either set these values in your code directly or ask the user for them (using the Scanner class). They could all be integers. Assume the robot moves forward d centimeter Compute and display the final location of the s. robot after it moves The new location is computed as point (x d cos(theta), y d sin(theta). Remember that the sine and cosine functions in JAVA useradians, not degrees P a ge I 4/4 To convert degrees to radians, you need to multiply the degrees by Math.PI/180 and ifyou need to convert from radians to degrees you can multiplythe radians by 180/Math.PI Write a class called RobotTest to test your code...remembering that 0 degrees is to the right (as shown below in red, 90 degrees is up, 180 degrees is left and the angle theta shown below is around 135 degrees. x-axis (cm)

Explanation / Answer

import java.lang.*;

class Robot
{


int x,y,D,Th;
   public Robot()
   {

   x=20;
y=20;
Th=90;
   D=30;

   }

   void compute()
   {
   x=x+D*(int)Math.cos(Th*(Math.PI/180));
y=y+D*(int)Math.sin(Th*(Math.PI/180));
System.out.println("New X coordinate is " + x);
System.out.println("New Y coordinate is " + y);


   }

   public static void main(String[] args) {

   Robot r=new Robot();
   r.compute();
}

}

======================================

akshay@akshay-Inspiron-3537:~$ javac Robot.java
akshay@akshay-Inspiron-3537:~$ java Robot
New X coordinate is 20
New Y coordinate is 50

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote