Stage 0: Add Java fundamentals exercises - #81
Conversation
d44b835 to
d0e40bf
Compare
|
|
||
| // Create an integer variable `quotient1`, and assign to it the value | ||
| // of 5 divided by 3. Then print the value of `quotient1`. | ||
| double quotient1 = 5 / 3; |
There was a problem hiding this comment.
In 2027, WPILib has a compiler plugin that will throw a compile-time error if someone tries to do this.
So, make it an int instead (and let people know that regular java doesn't error when you do integer division like this).
There was a problem hiding this comment.
Even though it will throw an error, I still think it's valuable to showcase what happens here to better explain why there's an error and why it's problematic. Plus, I don't want to include something that's wrong in normal java, even if wpilib makes it not wrong, in a way.
There was a problem hiding this comment.
Do you mean converting quotient1 to an int is wrong, or that keeping it as a double is wrong in normal Java?
There was a problem hiding this comment.
I meant keeping it as a double, my bad.
My main concern is that this code doesn't pass CI (also, y'all got it backwards: it's wrong in WPILib java, but not in normal java).
|
🌐 Preview URL: https://pr-81.frcsoftware.pages.dev |
| @@ -0,0 +1,54 @@ | |||
| void main() { | |||
| // Using the variable `turretEnabled` below, decide whether to turn on | |||
There was a problem hiding this comment.
comment mentioned turretEnabled, but code has shooterEnabled
| } | ||
| System.out.println(turretVelocity); | ||
|
|
||
| // Using only the NOT EQUALS TO operator, and the variable `statusCode` below, |
There was a problem hiding this comment.
I think the operator name is just NOT EQUALS
| // Create an integer variable `result`. Multiply the sum of 1 + 6 by the | ||
| // difference of 7 and 8, and store it in this variable. Then, print | ||
| // the value of `result`. |
There was a problem hiding this comment.
'Using java math operators, multiply...'
|
|
||
| // Create an integer variable `quotient1`, and assign to it the value | ||
| // of 5 divided by 3. Then print the value of `quotient1`. | ||
| double quotient1 = 5 / 3; |
| // Now, print all three variables in the **same** print statement, | ||
| // separated by spaces. | ||
| System.out.println(pi + " " + g + " " + mode); |
There was a problem hiding this comment.
Any lessons on string formatting?
Description
Adds exercises for stage 0 (Java Fundamentals), to complement the stage 0 lessons being built up.
Meta
Merge checklist: