Skip to content

Instantly share code, notes, and snippets.

View andersonmo's full-sized avatar

Anderson M Oliveira andersonmo

View GitHub Profile
@andersonmo
andersonmo / CompareSortingAlgorithm.java
Last active November 9, 2021 16:22
A simple way to show three common ways of sorting data using Java. Bubble Sort, Selection Sort and Insertion Sort.
public class CompareSortingAlgorithm {
public static void main(String[] args) {
Long startTime;
Long finishTime;
Long elapsedTime;
Integer[] arrayUnordered = new Integer[] {30, 21, 25, -8, 4, 67, 91, 48};
@andersonmo
andersonmo / CarpetCostCalculator_Calculator.java
Last active October 2, 2019 04:37
Application to calculate the price of carpeting for retangular rooms.
public class Calculator {
private Floor floor;
private Carpet carpet;
public Calculator(Floor floor, Carpet carpet){
this.floor = floor;
this.carpet = carpet;
}
public double getTotalCost(){
@andersonmo
andersonmo / DigitalWallet.java
Created August 14, 2019 05:40
Q2 - Java Exceptions: Digital Wallet (www.hackerrank.com)
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/*
* Create TransactionException, DigitalWallet, and DigitalWalletTransaction classes here.
*/
//---- My code ----
class TransactionException extends Exception {
@andersonmo
andersonmo / reformatDate.java
Created August 14, 2019 05:35
Q3 - Reformatting Dates (www.hackerrank.com)
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
@andersonmo
andersonmo / openAndClosePrices.java
Last active May 15, 2022 18:44
Q4 - Stock Open Close Price on Particular Weekdays (www.hackerrank.com)
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.net.*;
import com.google.gson.*;
//------ My code -----------
import java.io.InputStreamReader;