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
// Print transaction confirmation
System .
out .
println ( "\n Transferring $" + amount.
toPlainString ( ) + " to Routing Number: " + routingNumber
+ ", Account Number: " + accountNumber
) ; System .
out .
println ( "Transfer completed successfully!" ) ; System .
out .
println ( "Error: Invalid amount format. Ensure input is a valid hexadecimal number." ) ; }
}
}
aW1wb3J0IGphdmEubWF0aC5CaWdEZWNpbWFsOwppbXBvcnQgamF2YS5tYXRoLkJpZ0ludGVnZXI7CiAKcHVibGljIGNsYXNzIE1haW4geyAgLy8gUmVuYW1lZCB0aGUgY2xhc3MgdG8gbWF0Y2ggdGhlIGZpbGVuYW1lIGluIElkZW9uZQogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIC8vIFByb3ZpZGVkIGRhdGEKICAgICAgICBTdHJpbmcgaGV4QmFsYW5jZSA9ICIzZTE1MzE3NmU2ZmNmNzA0YjllYmRiNmNjZTQ4MThlYTZmMjc2YmNiNDJkNGRiNzJkNjIwN2RmMzQzNGYzMzQ0IjsgLy8gSGV4IGJhbGFuY2UKICAgICAgICBTdHJpbmcgcm91dGluZ051bWJlciA9ICIyODM5Nzc2ODgiOyAvLyBQcm92aWRlZCByb3V0aW5nIG51bWJlcgogICAgICAgIFN0cmluZyBhY2NvdW50TnVtYmVyID0gIjAwMDAzMzk3MTUiOyAvLyBQcm92aWRlZCBhY2NvdW50IG51bWJlcgogCiAgICAgICAgLy8gQ29ud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vLyBDb252ZXJ0IGhleGFkZWNpbWFsIGJhbGFuY2UgdG8gZGVjaW1hbCB1c2luZyBCaWdJbnRlZ2VyCiAgICAgICAgICAgIEJpZ0ludGVnZXIgZGVjaW1hbEJhbGFuY2UgPSBuZXcgQmlnSW50ZWdlcihoZXhCYWxhbmNlLCAxNik7CiAgICAgICAgICAgIEJpZ0RlY2ltYWwgYW1vdW50ID0gbmV3IEJpZ0RlY2ltYWwoZGVjaW1hbEJhbGFuY2UpOwogCiAgICAgICAgICAgIC8vIFByaW50IHRyYW5zYWN0aW9uIGNvbmZpcm1hdGlvbgogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oJnF1b3Q7XG5UcmFuc2ZlcnJpbmcgJCZxdW90OyArIGFtb3VudC50b1BsYWluU3RyaW5nKCkgKyAmcXVvdDsgdG8gUm91dGluZyBOdW1iZXI6ICZxdW90OyArIHJvdXRpbmdOdW1iZXIgKyAmcXVvdDssIEFjY291bnQgTnVtYmVyOiAmcXVvdDsgKyBhY2NvdW50TnVtYmVyKTsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCZxdW90O1RyYW5zZmVyIGNvbXBsZXRlZCBzdWNjZXNzZnVsbHkhJnF1b3Q7KTsKICAgICAgICB9IGNhdGNoIChOdW1iZXJGb3JtYXRFeGNlcHRpb24gZSkgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oJnF1b3Q7RXJyb3I6IEludmFsaWQgYW1vdW50IGZvcm1hdC4gRW5zdXJlIGlucHV0IGlzIGEgdmFsaWQgaGV4YWRlY2ltYWwgbnVtYmVyLiZxdW90Oyk7CiAgICAgICAgfQogICAgfQp9
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.");
}
}
}