Skip to content

Instantly share code, notes, and snippets.

@imryan
imryan / Tax.java
Last active December 28, 2015 16:39
CS 2 test. Calculates tax rate based on income.
import java.util.*;
import java.text.*;
public class Tax {
public static void main(String[] args) {
// Declare double values to be used in the program
double income = 0;
String taxRate = "";
@imryan
imryan / Bottles.java
Last active December 27, 2015 00:18
Bottles of soda on the wall, since beer is bad.
import java.util.Scanner;
public class Bottles
{
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
int verses = 0;
@imryan
imryan / Number.java
Created October 30, 2013 16:50
Determines odd/even/zeros in a numerical value.
import java.util.Scanner;
public class Numbers
{
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
int evens = 0, odds = 0, zeros = 0;
int number = 0;
@imryan
imryan / Leap.java
Last active December 26, 2015 21:49
Determines leap years.
import java.util.Scanner;
public class Leap {
public static void main(String[] args) {
// Call menu method
menu();
}
@imryan
imryan / Prime.java
Last active December 26, 2015 11:09
Prime number calculator.
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
// Declare a new Scanner object and an integer
Scanner sc = new Scanner(System.in);
int n = 0;
@imryan
imryan / Factorial.java
Last active December 26, 2015 09:19
Calculates factorials of n. Possibly wrong.
import java.util.*;
public class Factorial {
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
int n = 0, total = 1;
@imryan
imryan / Root.java
Last active December 26, 2015 09:18
Calculates square root of 25 and 5 less until 0 is reached.
public class Root {
public static void main(String[] args)
{
// Declare base as an integer with a value of 30
int base = 30;
while (base != 0) {
@imryan
imryan / Count.java
Last active December 26, 2015 08:29
Counts to 100, adding each number inclusively.
public class Count {
public static void main(String[] args)
{
// Declare variables
int i = 0;
int index = 0;
while (i != 100)
{
@imryan
imryan / Payroll.java
Last active December 26, 2015 08:29
Calculates payroll.
import java.util.Scanner;
import java.text.*;
public class Payroll {
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
double wage = 0.0, hours = 0.0;
@imryan
imryan / Tax.java
Last active December 26, 2015 05:58
Calculates income tax with dependencies.
import java.util.Scanner;
import java.text.*;
public class Tax {
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
final double TAX_RATE = 0.2;