Created
December 27, 2017 05:24
-
-
Save hendrawd/07088cc387b240124b229973f412bde9 to your computer and use it in GitHub Desktop.
BukaReksaAnnualPercentageFrom3MonthsCalculator.kt
This file contains hidden or 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
fun main(args: Array<String>) { | |
println("This program will calculate annual interest of BukaReksa based on 3 months price") | |
println("Input start price") | |
val startPrice = readLine()!!.toDouble() | |
println("Input end price") | |
val endPrice = readLine()!!.toDouble() | |
println("Annual interest is ${calculateAnnualInterest(startPrice, endPrice)}") | |
} | |
/** | |
* Calculate Annual interest based on start price and end price after 3 months period | |
*/ | |
private fun calculateAnnualInterest(startPrice: Double, endPrice: Double): String { | |
val percent = (endPrice - startPrice) / startPrice * 100 * 4 | |
// both below method return the same result | |
// return "${DecimalFormat("#.#####").format(percent)}%" | |
return "${String.format("%.5f", percent)}%" | |
} | |
// hasil cek annual interest di tanggal 25 Desember 2017 | |
// pasar uang | |
// 6.17311 CIMB-PRINCIPAL Bukareksa Pasar Uang | |
// 6.77242% Reksa Dana Syariah Mandiri Bukareksa Pasar Uang | |
// pendapatan tetap | |
// 9.96690% CIMB-Principal Total Return Bond Fund | |
// 20.08363% Syailendra Fixed Income Fund | |
// 12.30109% Mandiri Investa Dana Syariah | |
// campuran | |
// 15.95017% Kresna Flexima | |
// 2.05082% Cipta Syariah Balance | |
// saham | |
// 18.34288% BNP Paribas Pesona - masih terlalu fluktuatif grafiknya | |
// -7.40085% BNP Paribas Pesona Syariah |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment