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) { | |
int a = -4; | |
if ( (a < 0) || (a > 10) ) { | |
System.out.println("a is less than 0 or greater than 10."); | |
} | |
} |
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); | |
// Means that I do not have a sword | |
boolean youHaveASword = false; | |
String userChoice; | |
// Does the user pick up the sword | |
System.out.print("You see a sword lying next to the river. \nWould you like to pick it up? (y or n) "); |
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 DoWhileLoop { | |
public static void main(String[] args) { | |
boolean condition = true; | |
do { | |
// code that will repeat goes here |
OlderNewer