diff --git a/app/src/main/java/com/example/tiptime/MainActivity.kt b/app/src/main/java/com/example/tiptime/MainActivity.kt
index d8ccd56..a018c97 100644
--- a/app/src/main/java/com/example/tiptime/MainActivity.kt
+++ b/app/src/main/java/com/example/tiptime/MainActivity.kt
@@ -79,9 +79,9 @@ fun TipTimeLayout() {
var tipInput by remember { mutableStateOf("") }
var roundUp by remember { mutableStateOf(false) }
- val amount = amountInput.toDoubleOrNull() ?: 0.0
- val tipPercent = tipInput.toDoubleOrNull() ?: 0.0
- val tip = calculateTip(amount, tipPercent, roundUp)
+ val BmiHeight = amountInput.toDoubleOrNull() ?: 0.0
+ val BmiWeight = tipInput.toDoubleOrNull() ?: 0.0
+ val tip = calculateBMI(BmiHeight, BmiWeight, roundUp)
Column(
modifier = Modifier
@@ -99,8 +99,8 @@ fun TipTimeLayout() {
.align(alignment = Alignment.Start)
)
EditNumberField(
- label = R.string.bill_amount,
- leadingIcon = R.drawable.money,
+ label = R.string.height,
+ leadingIcon = R.drawable.number,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Next
@@ -110,8 +110,8 @@ fun TipTimeLayout() {
modifier = Modifier.padding(bottom = 32.dp).fillMaxWidth(),
)
EditNumberField(
- label = R.string.how_was_the_service,
- leadingIcon = R.drawable.percent,
+ label = R.string.weight,
+ leadingIcon = R.drawable.number,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done
@@ -126,7 +126,7 @@ fun TipTimeLayout() {
modifier = Modifier.padding(bottom = 32.dp)
)
Text(
- text = stringResource(R.string.tip_amount, tip),
+ text = stringResource(R.string.bmi_calculation, tip),
style = MaterialTheme.typography.displaySmall
)
Spacer(modifier = Modifier.height(150.dp))
@@ -163,7 +163,7 @@ fun RoundTheTipRow(
modifier = modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
- Text(text = stringResource(R.string.round_up_tip))
+ Text(text = stringResource(R.string.use_usc))
Switch(
modifier = Modifier
.fillMaxWidth()
@@ -175,16 +175,16 @@ fun RoundTheTipRow(
}
/**
- * Calculates the tip based on the user input and format the tip amount
- * according to the local currency.
- * Example would be "$10.00".
+ * Calculates the BMI
+ *
+ * Catatan: tambahkan unit test untuk kalkulasi BMI ini
*/
-private fun calculateTip(amount: Double, tipPercent: Double = 15.0, roundUp: Boolean): String {
- var tip = tipPercent / 100 * amount
+private fun calculateBMI(BmiHeight: Double, BmiWeight: Double = 15.0, roundUp: Boolean): String {
+ var tip = BmiWeight / 100 * BmiHeight
if (roundUp) {
tip = kotlin.math.ceil(tip)
}
- return NumberFormat.getCurrencyInstance().format(tip)
+ return NumberFormat.getNumberInstance().format(tip)
}
@Preview(showBackground = true)
@@ -193,4 +193,4 @@ fun TipTimeLayoutPreview() {
TipTimeTheme {
TipTimeLayout()
}
-}
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/money.xml b/app/src/main/res/drawable/number.xml
similarity index 100%
rename from app/src/main/res/drawable/money.xml
rename to app/src/main/res/drawable/number.xml
diff --git a/app/src/main/res/drawable/percent.xml b/app/src/main/res/drawable/percent.xml
deleted file mode 100644
index e593384..0000000
--- a/app/src/main/res/drawable/percent.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 26d4260..6db9d41 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -15,10 +15,11 @@
~ limitations under the License.
-->
- Tip Time
- Calculate Tip
- Bill Amount
- Tip Percentage
- Round up tip?
- Tip Amount: %s
+ BMI Calculator
+ Calculate BMI
+ Tinggi Badan
+ Berat Badan
+ Gunakan Unit USC (lbs/in)?
+
+ BMI Anda: %s