Skip to content

Instantly share code, notes, and snippets.

@joeyv
joeyv / Sum.java
Last active December 26, 2015 11:39
Adds 1 - 100 inclusively
class Sum {
public static void main(String[] args) {
int i = 0, sum = 0;
// Loop adds numbers 1 = 100
while(i < 100){
i++;
sum += i;
}
@joeyv
joeyv / Payroll.java
Created October 24, 2013 17:20
calculate your payroll
import java.util.Scanner;
import java.text.*;
public class Payroll{
public static void main(String []args){
double hourPay, hourWorked;
double overtime, total;
@joeyv
joeyv / Tax.java
Created October 24, 2013 12:50
Calculates your tax cost
import java.util.Scanner;
import java.text.*;
public class Tax {
public static void main(String[] args)
{
// Declare variables
int allowedDeduction = 10000, deduction = 2000;
int grossIncome, dependents;
@joeyv
joeyv / Sphere.java
Last active December 26, 2015 10:28
Calculates Volume and Surface Area of a sphere
import java.util.Scanner;
import java.text.*;
public class Sphere
{
public static void main(String[] args)
{
double pi = Math.PI;
double radius, volume, surfaceArea;
@joeyv
joeyv / Usernames.java
Last active December 26, 2015 08:39
Generates a username based off of the first letter of your name, the first 5 letters of your last name, and a random 2 digit number.
import java.util.*;
public class Usernames {
public static void main(String[] args) {
String first, last, username;
int randomNum;
// Scan in first and last name
@joeyv
joeyv / Distance.java
Last active December 26, 2015 05:59
Simple program to calculate the distance of two coordinates
import java.util.*;
public class Distance
{
public static void main(String[] args)
{
int x1, y1;
int x2, y2;
int inside, distance;
@joeyv
joeyv / Cubes.java
Created October 21, 2013 17:34
Cubes two inputs and adds them
import java.util.Scanner;
public class Cubes
{
public static void main(String[] args)
{
// Declare variables
double cube1, cube2;
double sum;
@joeyv
joeyv / Stringmynips.java
Created October 21, 2013 17:34
idk lol
import java.util.Scanner;
public class StringManips
{
public static void main (String[] args)
{
String phrase = new String ("This is a String test.");
int phraseLength; // number of characters in the phrase String
int middleIndex; // index of the middle character in the String
String firstHalf; // first half of the phrase String
@joeyv
joeyv / PhoneNum.java
Last active September 21, 2023 13:41
Generates a random phone number
import java.util.*;
public class Phone
{
public static void main(String[] args)
{
int num1, num2, num3; //3 numbers in area code
int set2, set3; //sequence 2 and 3 of the phone number
Random generator = new Random();
@joeyv
joeyv / Lottery.java
Created October 18, 2013 16:58
Lottery number generator
import java.util.*;
public class Lottery
{
public static void main(String []args)
{
// 6 Lottery numbers
int num1, num2, num3, num4, num5, num6;
// Random number generator