Skip to content

Instantly share code, notes, and snippets.

@marce11o
marce11o / Chapter 17 (BitOutputStream)
Last active February 23, 2016 01:44
Liang Chapter 17
/*
* BitOutputStream.class
*/
package chapter.pkg17;
import java.io.*;
/**
*
* @author Marcello
*/
public class BitOutputStream {
@marce11o
marce11o / ch16exercises
Last active December 16, 2015 05:06
Chapter 16
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Ch16Exercises;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
@marce11o
marce11o / Chapter 15 Exercises
Last active February 27, 2024 19:02
Chapter 15 Exercises
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ch15exercises;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.application.Application;
@marce11o
marce11o / ch14exercises.java
Last active October 9, 2015 01:20
Chapter 14 - JavaFX Basics
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ch14exercises;
//import java.io.File;
//import java.awt.Transparency;
import javafx.application.Application;
@marce11o
marce11o / MyStack13
Last active March 2, 2016 04:18
Chapter 13 - Abstract Classes and Interfaces
import java.util.ArrayList;
public class MyStack13 {
private ArrayList<Object> list = new ArrayList<>();
public boolean isEmpty() {
return list.isEmpty();
}
@marce11o
marce11o / Eraatosthenes
Created June 29, 2015 01:34
Sieve of Eratosthenes (Prime Number Finder) - uses command line arguments
import java.util.*;
import java.io.*;
/*
Implement the sieve of Eratosthenes: a method for computing
prime numbers, known to the ancient Greeks. This method will
compute all prime numbers up to n. Choose an n. First insert
all numbers from 2 to n into a set. Then erase all multiples
of 2 (except 2); that is, 4, 6, 8, 10, 12, … . Erase all
multiples of 3; that is, 6, 9, 12, 15, … . Go up to n. Then
@marce11o
marce11o / PrimeNumberFinder
Created June 29, 2015 01:32
Prime Number Finder - uses command line arguments
import java.util.*;
import java.io.*;
public class myJava
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int num = Integer.parseInt(args[0]);
int numOfPrimes = 0;
@marce11o
marce11o / MagicSquare
Created June 29, 2015 01:30
Magic Square
/**
*@author Marcello Liguori
*/
//Write a program whose input is the number n and whose
//output is the magic square of order n if n is odd.
/*
Test case: 5
Output...
11 18 25 2 9
@marce11o
marce11o / Diamond
Created June 29, 2015 01:27
Diamond
import java.util.Scanner;
public class TXP_Exercises
{
/* Diamond algorithm - by Marcello Liguori
*/
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: "); // length of diamond sides
@marce11o
marce11o / BarGraph
Created June 29, 2015 01:25
Bar Graph
import java.util.Scanner;
import java.util.ArrayList;
/**
* Takes string and integer input from user and outputs bar graph.
*@author Marcello Liguori
*
*Example: USA Japan 2 3
*
* USA: **
* Japan: ***