Help with code

We ar having some errors in this area of our code.

  1. double xinput = oi.getDriverJoystick().getX();

  2. double yinput = oi.getDriverJoystick().getY();

  3. if (xinput < 0) {

  4. xinput = -Math.pow(xinput, 2);

  5. }

  6. else {

  7. xinput = Math.pow(xinput, 2);

  8. }

  9. if (yinput < 0) {

  10. yinput = -Math.pow(yinput,2);

  11. }

  12. else {
    184 ) yinput = Math.pow(yinput, 2);

  13. }

187 ) left.set(yinput-xinput);
188) right.set(-yinput-xinput);

Here are the errors that we are getting

C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:172: error: illegal start of type
if (xinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:172: error: illegal start of type
if (xinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:175: error: illegal start of type
else {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:179: error: illegal start of type
if (yinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:179: error: illegal start of type
if (yinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:182: error: illegal start of type
else {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:186: error: expected
left.set(yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:186: error: expected
left.set(yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:187: error: expected
right.set(-yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:187: error: illegal start of type
right.set(-yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:195: error: class, interface, or enum expected
}

Upload all of your code to Github or another code sharing service so that it is easier for others to help you.

Here is the github link.
Here are the errors again.
Thank you
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:172: error: illegal start of type
if (xinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:172: error: illegal start of type
if (xinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:175: error: illegal start of type
else {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:179: error: illegal start of type
if (yinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:179: error: illegal start of type
if (yinput < 0) {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:182: error: illegal start of type
else {
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:186: error: expected
left.set(yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:186: error: expected
left.set(yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:187: error: expected
right.set(-yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:187: error: illegal start of type
right.set(-yinput-xinput);
^
C:\2020Coding\Bizcuit\src\main\java\frc\robot\Robot.java:195: error: class, interface, or enum expected
}

Your immediate problem is the stray } on 157. You need to comment that line out to match its neighbors.

One of the things I do in my own programming is to put a comment on every closing } to match its opening counterpart. I haven’t talked to my programmers lately about this practice. Thanks for jogging my memory!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.