-
Notifications
You must be signed in to change notification settings - Fork 1
Performance Test (Intermediate Level)
The code below is designed to print all the numbers from the list testList There are ways to optimize it too if you find them, however that is not required.
index = 0 testList = [2,5,7,4,11]
while index < 6: print(testList[index]) index += 1
public class JavaTest2 { public static void main(String[] args) {
Integer index = 0;
Integer[] testList = {2,5,7,4,11};
while (index < 6) {
System.out.println(testList[index]);
index += 1;
}
} }
minecraftCost = 24.99 tShirtCost = 18.99 raspberryPiCost = 999.99 tax = 1.1
print("Hello user!") displayText = "The cost of this item is " + str(minecraftCost) print(displayText) taxCost = minecraftCost * 1.1 print("With tax, this item will cost " + str(taxCost))
print("Hello user!") displayText = "The cost of this item is " + str(tShirtCost) print(displayText) taxCost = tShirtCost * 1.1 print("With tax, this item will cost " + str(taxCost))
print("Hello user!") displayText = "The cost of this item is " + str(raspberryPiCost) print(displayText) taxCost = raspberryPiCost * 1.1 print("With tax, this item will cost " + str(taxCost))
public class JavaTest { public static void main(String[] args) {
Double minecraftCost = 24.99;
Double tShirtCost = 18.99;
Double raspberryPiCost = 999.99;
Double tax = 1.1;
System.out.println("Hello User!");
String originalCost = "The cost of this item is: " + minecraftCost * tax;
System.out.println(minecraftCost);
Double taxCost = minecraftCost * tax;
System.out.println("With tax, this item costs: " + taxCost);
System.out.println("Hello User!");
originalCost = "The cost of this item is: " + tShirtCost * tax;
System.out.println(originalCost);
taxCost = tShirtCost * tax;
System.out.println("With tax, this item costs: " + taxCost);
System.out.println("Hello User!");
originalCost = "The cost of this item is: " + raspberryPiCost * tax;
System.out.println(originalCost);
taxCost = raspberryPiCost * tax;
System.out.println("With tax, this item costs: " + taxCost);
}
}
Create a program that...
- Will ask the user for there name and age repeatedly
- uses an if statement to stop the loop
- once the loop is over, print out all the names and there ages
in order to get input from the user, you can use the method below input() an example can be seen below userInput = input("What is your eye color")
As seen from the example, you can create a variable, and store the user input in it You may have also noticed that there is a string as a parameter in the input method. This string will be printed to the terminal whenever the mehtod is run
In order to get input from the user, first you must import the scanner method import java.util.Scanner Then, you must create the Scanner Object Scanner scanObject = new Scanner(System.in); // Create Scanner object in order to get input, you must use this method of the the Scanner object (scanObject) String userInput = scanObject.nextLine();
an example of this in full swing can be seen below
import java.util.Scanner;
public class JavaTest3 { public static void main(String[] args) {
Scanner scanObject = new Scanner(System.in); // Create Scanner object
System.out.println("Enter your social security number!");
String SSN = scanObject.nextLine(); // get user input, store it on String "SSN"
System.out.println("Your Social Security Number is: " + SSN); // output
} }
-
- 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