Skip to content

Instantly share code, notes, and snippets.

@imryan
imryan / Sphere.java
Last active April 12, 2023 18:28
Calculates volume and surface area of a sphere's radius.
import java.util.Scanner;
import java.text.*;
public class Sphere
{
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
final double PI = Math.PI;
@imryan
imryan / Usernames.java
Created October 18, 2013 16:50
Username generator.
import java.util.*;
public class Usernames {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
String first, last, username;
@imryan
imryan / Distance.java
Created October 18, 2013 16:41
Distance formula calculator.
import java.util.*;
public class Distance {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
int x1, x2, y1, y2;
@imryan
imryan / Phone.java
Last active December 25, 2015 19:39
Generates a random phone number.
import java.util.*;
public class Phone
{
public static void main(String[] args)
{
// Declare variables
int areaCode = 0;
int sequence1 = 0, sequence2 = 0;
String number = "";
@imryan
imryan / Cubes.java
Last active December 25, 2015 19:29
Calculates the sum of cubes.
import java.util.Scanner;
public class Cubes
{
public static void main(String[] args)
{
// Declare variables
Scanner sc = new Scanner(System.in);
int cube1, cube2;
double sum;
@imryan
imryan / Lottery.java
Last active December 25, 2015 17:18
Generates random lottery numbers.
import java.util.*;
public class Lottery
{
public static void main (String[] args)
{
// Create an ArrayList of integers to store the 6 random numbers
ArrayList<Integer> numbers = getLotteryNumbers();
// Print the results
@imryan
imryan / Dice.java
Last active December 25, 2015 17:09
Rolls dice.
import java.util.*;
public class Dice
{
public static void main (String[] args)
{
// Call the roll method
rollDice();
}
@imryan
imryan / Replace.java
Created October 16, 2013 16:39
Replace chars in a string.
import java.util.Scanner;
public class Replace {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
String word = "", newWord = "";
@imryan
imryan / shellcast.py
Last active December 25, 2015 09:59
Current weather brought to you in the CLI.
# shellcast
# Main application file
import sources
import pywapi
import string
def main():
print("Welcome to shellcast.\n\nNote: If your zipcode begins with a 0, type the zipcode without the zero.\n")
@imryan
imryan / Change.java
Created October 11, 2013 17:29
Calculates change.
import java.util.Scanner;
class Hello {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
final int QUARTER = 25;
final int DIME = 10;