Skip to content

Instantly share code, notes, and snippets.

@jimmykurian
jimmykurian / Instructor.java
Created March 13, 2012 05:27
A super class Person with two subclasses, Student and Instructor, that inherit from Person. A person has a name and a year of birth. A student has a major, and an instructor has a salary.
//Instructor.java - Jimmy Kurian
public class Instructor extends Person
{
private double salary;
public Instructor(String n, int byear, double s)
{
super(n, byear);
salary = s;
@jimmykurian
jimmykurian / SavingsAccount.java
Created February 3, 2012 21:45
A Java program that creates a Bank Account with withdraw, deposit, and intrest functions. And a tester class, that tests the SavingsAccount class.
//SavingsAccount.java - Jimmy Kurian
public class SavingsAccount
{
private double balance;
private double interest;
public SavingsAccount()
{
balance = 0;
@jimmykurian
jimmykurian / BarChart.java
Created February 18, 2012 02:25
A Java program that displays a bar chart of the added values.
//BarChart.java - Jimmy Kurian
import java.util.ArrayList;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.Rectangle;
public class BarChart
{
@jimmykurian
jimmykurian / BankAccount.py
Created February 6, 2012 16:41
A BankAccount program with classes, written in Python.
# BankAccount.py - Jimmy Kurian
class BankAccount(object):
def __init__(self, initial_balance=0):
self.balance = initial_balance
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
self.balance -= amount
def overdrawn(self):
@jimmykurian
jimmykurian / HelloWorld.scm
Created February 17, 2012 18:09
A simple Hello World program written in the Scheme programming language.
;HelloWorld.scm - Jimmy Kurian
(begin
(display "Hello, World!")
(newline))
@jimmykurian
jimmykurian / CheckerBoard.java
Created February 3, 2012 22:12
A graphical application that displays a 8x8 chess board with 64 squares, alternating black and white.
//CheckerBoard.java - Jimmy Kurian
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Color;
public class CheckerBoard extends JFrame
{
public void paint(Graphics g)
@jimmykurian
jimmykurian / Square.java
Created February 18, 2012 01:57
A Java program that reads in n^2 values from the keyboard and test whether they form a magic square when arranged as a square matrix.
//Square.java - Jimmy Kurian
import java.util.Scanner;
public class Square
{
//Constructs a n x n square filled with zeros.
public Square(int n)
{
@jimmykurian
jimmykurian / Employee.java
Created April 21, 2012 22:43
A simple Java program to keep track of employees in a company which implements HashMap and TreeSet data sructures.
//Employee.java - Jimmy Kurian
public class Employee implements Comparable<Employee>
{
private String ssn;
private String lastName;
private String firstName;
public int compareTo(Employee emp)
@jimmykurian
jimmykurian / Sum10.java
Created February 3, 2012 21:41
A Java program named Sum10 that computes the sum of the first ten positive integers 1+2+ … +10. Print the result to the standard output.
//Sum10.java - Jimmy Kurian
class Sum10{
public static void main(String[] args) {
int s = 1+2+3+4+5+6+7+8+9+10;
System.out.println(s);
}
}
@jimmykurian
jimmykurian / Geometry.java
Created February 21, 2012 05:38
A Java program that will compute the volume and surface area of a sphere with radius r, a cylinder with circular base with radius r and height h, and a cone with circular base with radius r and height h.
//Geometry.java - Jimmy Kurian
public class Geometry
{
public static double sphereVolume(double r)
{
return (4.0 / 3.0) * Math.PI * r * r * r;
}