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
this_string = input("Input a string: ") | |
reversed_string = "".join(reversed(this_string)) | |
if this_string == reversed_string: | |
print("The string you provided is a palindrome.") | |
else: | |
print("The string you provided is not a palindrome.") | |
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
# Define x | |
x = 0 | |
# Define for-loop that starts with x and uses the range function to go from 1 to 100 | |
for x in range(1,101): | |
# Print out "FizzBuzz" if a number in the range is divisible by 3 AND 5 | |
if x%3 == 0 and x%5 == 0: | |
print("FizzBuzz") | |
# Print out "Fizz" if a number in the range is divisible by 3 |
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 CracklePop { | |
public static void main(String args[]){ | |
for(int num = 1; num <= 100; num++){ | |
if(num % 3 == 0 && num % 5 == 0){ | |
System.out.println("CracklePop"); | |
}else if(num % 3 == 0){ | |
System.out.println("Crackle"); |
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
/** | |
* When the javadoc tool is run over this code, it will bring up the | |
* HTML maintenance manual. | |
* @author LTagliaferri | |
* @version 1.0 | |
*/ | |
public class CountUpExample { | |
/** | |
* This method counts up from a specified 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
import java.util.Scanner; | |
import java.util.Random; | |
public class MagicNumber { | |
private static void playTheGame(int magicNumber) { | |
int numberOfTries = 0; | |
Scanner input = new Scanner(System.in); | |
int guess; |
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 LeapYear { | |
public static void main (String args[]) { | |
int year = Integer.parseInt(args[0]); | |
if ((year % 4 == 0) && (year % 100 != 0)){ | |
System.out.println(year + " is a leap year."); | |
} | |
else if ((year % 100 == 0) && (year % 400 == 0)){ | |
System.out.println(year + " is a leap year."); |
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
import java.io.*; | |
public class BMICalculator { | |
public static void main(String[] args) { | |
int i = 100; | |
String s1 = getInput("Your weight in kg: "); | |
String s2 = getInput("Your height in cm: "); | |
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
/**RockPaperScissors class creates PlayTheGame contains the methods for | |
* playing the game of rock paper scissors. | |
* | |
* @author Lisa Tagliaferri | |
*/ | |
import java.util.Random; | |
import java.util.Scanner; | |
public class PlayTheGame { |
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 BlueRedTower extends Tower { | |
public BlueRedTower(){ | |
super(); | |
this.name = "Blue Red Tower"; | |
} | |
public int attackJelly() { | |
int pointValue = 1; | |
return pointValue; | |
} | |