Created
May 31, 2023 15:30
-
-
Save ievgiienko/f39230faa51db9b1fafc9d9434d58dc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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