This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cipher { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
String plaintext = "Oh say can you see"; | |
String ciphertext = ""; | |
String key = "shift"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cipher { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
String plaintext = "Oh say can you see"; | |
String ciphertext = ""; | |
String key = "shift"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ask the person a question they need to respond to | |
System.out.print("What is your name: "); | |
// Create a Scanner object to allow input from the user | |
Scanner inputString = new Scanner(System.in); | |
// Use the Scanner object to save the user's response, and put it into a String variable | |
String name = inputString.next(); | |
// Print using their response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare variables | |
Scanner input = new Scanner(System.in); | |
String favoriteFood; | |
int numberOfCandyBarsUserCanEat; | |
// Ask user for favorite food | |
System.out.print("What is your favorite food? "); | |
// Store response | |
favoriteFood = input.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Printing text | |
System.out.print("Hello class"); | |
// Printing a String | |
String name = "Dexter"; | |
System.out.print("Hello " + name); | |
// Printing an integer | |
int number = 8; | |
System.out.print("My number is " + number); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Printing text | |
System.out.printf("Hello class"); | |
// Printing a String | |
String name = "Dexter"; | |
System.out.printf("Hello %s", name); | |
// Printing an integer | |
int number = 8; | |
System.out.printf("My number is %d", number); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
int number = 0; | |
Scanner extraction; | |
while (number < 1 || number > 10) { | |
System.out.print("Enter a number (1-10): "); | |
String line = input.nextLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
// Variables | |
Scanner input = new Scanner(System.in); | |
int age; | |
// Ask a question and save their answer | |
System.out.print("Enter your age: "); | |
age = input.nextInt(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
// Variables | |
Scanner input = new Scanner(System.in); | |
String name; | |
// Ask and get the user's answer | |
System.out.print("Enter your name: "); | |
name = input.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
int a = 14; | |
if ( (a > 0) && (a < 10) ) { | |
System.out.println("a is between 0 and 10."); | |
} | |
else if (a >= 10 && a < 20) { | |
System.out.println("a is between 10 and 20, including 10."); | |
} |
OlderNewer