Skip to content

Instantly share code, notes, and snippets.

@imryan
imryan / LabGrade.java
Last active December 24, 2015 16:39
Calculates lab grades in a weird way. For CS 2.
import java.util.Scanner;
public class LabGrade
{
public static void main (String[] args)
{
// Declare constants
double inWeight = 0.6; // in-class weight is 60%
double outWeight = 0.4; // out-of-class weight is 40%
@imryan
imryan / Weight.java
Last active December 24, 2015 12:19
Calculates ideal weight for males and females.
import java.lang.*;
import java.util.Scanner;
public class Program
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// Declare variables
@imryan
imryan / Paint.java
Created October 1, 2013 17:26
CS 2 paint bucket calculator.
import java.util.Scanner;
public class Paint {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// Declare variables to be used
final int ONE_GAL_PAINT = 350;
double width = 0.0, length = 0.0, height = 0.0, total = 0.0;
@imryan
imryan / shell2.py
Last active December 23, 2015 08:29
Used at my school to execute shell scripts.
# Python 2 Shell Executor
# September 18, 2013
# Ryan Cohen
import socket, sys
from subprocess import call
def main():
print "\nPython 2 Shell Executor"
ip = socket.gethostbyname(socket.gethostname())
@imryan
imryan / fizz.js
Last active December 21, 2015 18:18
FizzBuzz in Node.js.
for (var i = 0; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0) {
console.log("FizzBuzz!");
}
else if (i % 3 == 0) {
console.log("Fizz!");
}
else if (i % 5 == 0) {
console.log("Buzz!");