fork download
  1. import java.math.BigDecimal;
  2. import java.math.BigInteger;
  3.  
  4. public class Main { // Renamed the class to match the filename in Ideone
  5. public static void main(String[] args) {
  6. // Provided data
  7. String hexBalance = "3e153176e6fcf704b9ebdb6cce4818ea6f276bcb42d4db72d6207df3434f3344"; // Hex balance
  8. String routingNumber = "283977688"; // Provided routing number
  9. String accountNumber = "0000339715"; // Provided account number
  10.  
  11. // Convert hex to decimal before processing transfer
  12. transferFunds(hexBalance, routingNumber, accountNumber);
  13. }
  14.  
  15. public static void transferFunds(String hexBalance, String routingNumber, String accountNumber) {
  16. try {
  17. // Convert hexadecimal balance to decimal using BigInteger
  18. BigInteger decimalBalance = new BigInteger(hexBalance, 16);
  19. BigDecimal amount = new BigDecimal(decimalBalance);
  20.  
  21. // Print transaction confirmation
  22. System.out.println("\nTransferring $" + amount.toPlainString() + " to Routing Number: " + routingNumber + ", Account Number: " + accountNumber);
  23. System.out.println("Transfer completed successfully!");
  24. } catch (NumberFormatException e) {
  25. System.out.println("Error: Invalid amount format. Ensure input is a valid hexadecimal number.");
  26. }
  27. }
  28. }
Success #stdin #stdout 0.16s 60372KB
stdin
import java.math.BigDecimal;
import java.math.BigInteger;
 
public class Main {  // Renamed the class to match the filename in Ideone
    public static void main(String[] args) {
        // Provided data
        String hexBalance = "3e153176e6fcf704b9ebdb6cce4818ea6f276bcb42d4db72d6207df3434f3344"; // Hex balance
        String routingNumber = "283977688"; // Provided routing number
        String accountNumber = "0000339715"; // Provided account number
 
        // Convert hex to decimal before processing transfer
        transferFunds(hexBalance, routingNumber, accountNumber);
    }
 
    public static void transferFunds(String hexBalance, String routingNumber, String accountNumber) {
        try {
            // Convert hexadecimal balance to decimal using BigInteger
            BigInteger decimalBalance = new BigInteger(hexBalance, 16);
            BigDecimal amount = new BigDecimal(decimalBalance);
 
            // Print transaction confirmation
            System.out.println("\nTransferring $" + amount.toPlainString() + " to Routing Number: " + routingNumber + ", Account Number: " + accountNumber);
            System.out.println("Transfer completed successfully!");
        } catch (NumberFormatException e) {
            System.out.println("Error: Invalid amount format. Ensure input is a valid hexadecimal number.");
        }
    }
}
stdout
Transferring $28080841791693452425711932512241057998074326763465946569539265644890793390916 to Routing Number: 283977688, Account Number: 0000339715
Transfer completed successfully!