Skip to content

Instantly share code, notes, and snippets.

@ievgiienko
Created May 31, 2023 15:30
Show Gist options
  • Save ievgiienko/f39230faa51db9b1fafc9d9434d58dc1 to your computer and use it in GitHub Desktop.
Save ievgiienko/f39230faa51db9b1fafc9d9434d58dc1 to your computer and use it in GitHub Desktop.
package org.example;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
var scanner = new Scanner(System.in);
System.out.println("What is BTC price today?");
var rate = scanner.nextDouble();
while (true) {
System.out.println("How mush $ do you have?");
var dollars = scanner.nextDouble();
if (dollars == 0)
break;
var result = dollars / rate;
System.out.println("Result = " + result);
}
}
}
package org.example;
import net.thauvin.erik.crypto.CryptoPrice;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
var scanner = new Scanner(System.in);
//System.out.println("What is BTC price today?");
//var rate = scanner.nextDouble();
var rate = CryptoPrice.spotPrice("BTC");
System.out.println("BTC price is " + rate.getAmount());
while (true) {
System.out.println("How mush $ do you have?");
var dollars = scanner.nextDouble();
if (dollars == 0)
break;
var result = dollars / rate.getAmount().doubleValue();
System.out.println("Result = " + result);
}
}
}
<dependencies>
<dependency>
<groupId>net.thauvin.erik</groupId>
<artifactId>cryptoprice</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment