add amount saved

This commit is contained in:
Kay Faraday 2024-08-02 23:48:01 +00:00
parent d48892751d
commit dc7f3c54ca
1 changed files with 2 additions and 1 deletions

View File

@ -29,7 +29,8 @@ class MainActivity : AppCompatActivity() {
val tax = BigDecimal(binding.taxEdit.text.toString())
val gratuityCoeff = BigDecimal(binding.gratuityEdit.text.toString())
val tip = gratuityCoeff * subtotal
displayMessage("Tip: $${tip}\nTotal: $${subtotal+tax+tip}")
val saved = gratuityCoeff * (subtotal + tax) - tip
displayMessage("Tip: $${tip}\nTotal: $${subtotal+tax+tip}\nYou saved: $${saved}")
} catch (e: NumberFormatException) {
displayMessage("Invalid number format")
}