-
Notifications
You must be signed in to change notification settings - Fork 1
Performance Test (Beginner Level)
Henry Hare edited this page Jun 7, 2023
·
9 revisions
Ini the beninging
The code below is designed to print "integer equals 5". However, when you run it, it returns an error. Adjust the code so it will run
_integer = 5_
_if integer = 5:_
_print("integer equals 5")_
public class JavaTest {
public static void main(String[] args) {
Integer integer = 5;
if (integer = 5) {
System.out.println("integer equals 5");
}
}
}
The code below functions, however, it can be optimized further. Adjust the code so it runs faster and clearer
_testValue = 11_
_result = testValue % 3_
_if result == 0:_
_print("Result = 0")_
_if result == 1:_
_print("Result = 1")_
_if result == 2:_
_print("Result = 2")_
public class JavaTest {
public static void main(String[] args) {
Integer testValue = 11;
Integer result = testValue % 3;
if (result == 0) {
System.out.println("result = 0");
}
if (result == 1) {
System.out.println("result = 1");
}
if (result == 2) {
System.out.println("result = 2");
}
}
}
Create a program that uses a boolean, a double/float, a modulus operator (%), and an if statement. Make sure to include comments in your program. For extra credit, use user input in your program too.
-
- Contributing
-
- General
- CTRE
-
NI
- RoboRio
-
REV
- SPARK Max Motor Controller
- NEO Brushless Motor
- Pneumatic Hub
- Radio Power Module
- POE Injector
- Power Distribution Hub
- Other
-
-
Java
- General
- Robot Integration
- Vendordeps
- CTRE Hardware
- NavX Hardware
- Ni Hardware
- Rev Hardware
-
Python
- General
- Data Types
- Operators
- Robot Integration
- Vendordeps
- CTRE Hardware
- NavX Hardware
- Ni Hardware
- Rev Hardware
- General
-
WPILib
- Installation
- Shuffle Board
- Smart Dashboard
-
NI / FRC Game Tools
- Installation
- Driver Station
- RoboRio Imaging Tool
-
Phoenix Framework
- Installation
- Phoenix Tuner
-
REV
- Installation
- REV Hardware Client
-
Java