View FileBrowser.java
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.io.*; | |
public class FileBrowser{ | |
private static String logName; | |
public FileBrowser(){ | |
logFile(); | |
run(); |
View Card.java
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 Card { | |
private int value; //didnt include suit because it messed with calculations (not important for the War game, but in the future I will try to include things like that for reuse-ability) | |
public Card(int i){ | |
value = i; | |
} | |
public int getCardValue(){ | |
return value; |
View Hangman.py
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 random; | |
# Repeatedly play the game of Hangman: | |
def play(): | |
maxAllowedAttempts = 8; | |
print rulesDisplay(maxAllowedAttempts); | |
listOfWords = inputListOfWords('words.txt'); | |
while (True): | |
playOneGame(maxAllowedAttempts, listOfWords); | |
ans = inputYesNo('\nPlay more? [Yes/No]: '); |
View StockTracker.py
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 urllib; | |
# Stock checkup - Download and display a stock quote: | |
def checkup(symbol): | |
keywords = ['Symbol', 'Price', 'Open', 'Date', 'Time', 'Volume']; | |
stock = getStock(symbol, keywords); | |
display(stock); | |
# Display stock quote from a dictionary: | |
def display(stock): |
View ScoreFiler.py
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
# Input student records from a file and return a list of records: | |
def read(fileName): | |
listOfStudents = []; | |
inFile = open(fileName, 'rU'); # read in "universal end-of-line" mode | |
for line in inFile: | |
# Strip unnecessary '\n' from right end: | |
line = line.rstrip('\n'); | |
student = line.split(','); | |
# student = ['last-name', 'first-name', 'score'] | |
listOfStudents.append(student); |
View StringFunctions.py
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
# Generate a string with all letters from the English alphabet. : | |
def alphabet(): | |
result = 'abcdefghijklmnopqrstuvwxyz'; | |
return result + result.upper(); | |
# Generate a randomly scrambled version of a string: | |
import random; | |
def scramble(string): | |
characterList = list(string); | |
random.shuffle(characterList); |
View Quiz1.py
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
[ | |
{ #question 1 | |
'type' : 'multiple-choice', | |
'text' : | |
'Who was the first U.S. President?\n' + | |
'(1) Abraham Lincoln\n' + | |
'(2) George Washington\n' + | |
'(3) John Lennon\n' + | |
'(4) Franklin Roosevelt', |
View SumOfPrimes.java
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 SumOfPrimes { | |
public SumOfPrimes(){ | |
System.out.println(sum(2000000)); //running the sum of primes limit to 2,000,000 [For Project Euler's answer] | |
} | |
public long sum(int limit){ //Project Euler wanted it for 2,000,000 but this method can do it for any limit given | |
boolean[] boolPrimes = new boolean[limit]; //initializing an array of booleans to the limit | |
boolPrimes[0] = false; //I know 0 isn't a prime | |
boolPrimes[1] = false;// I know 1 isn't a prime |
View GridProduct.java
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 GridProduct { | |
private int[][] grid = new int[][]{ | |
{8, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91, 8}, | |
{49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 04, 56, 62, 00}, | |
{81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 03, 49, 13, 36, 65}, | |
{52, 70, 95, 23, 04, 60, 11, 42, 69, 24, 68, 56, 01, 32, 56, 71, 37, 02, 36, 91}, | |
{22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80}, | |
{24, 47, 32, 60, 99, 03, 45, 02, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50}, | |
{32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70}, | |
{67, 26, 20, 68, 02, 62, 12, 20, 95, 63, 94, 39, 63, 8, 40, 91, 66, 49, 94, 21}, |
View TriangleNumber.java
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 TriangleNumber { | |
private int numDivisors; | |
public TriangleNumber(int numDivisors){ //takes in how many divisors | |
this.numDivisors = numDivisors; | |
} | |
public int firstOccurance(){ //returns the first occurance of the number of divisors you want the triangle number to have | |
int i = 1; |
OlderNewer