Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ejercicio.- Redondear el cambio (Curso de Kotlin desde cero [24])
Video: https://youtu.be/e8wPTxU6SmY
- Loading branch information
1 parent
2d882cd
commit fe457b8
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import java.lang.Exception | ||
import kotlin.math.ceil | ||
println("Bienvenido a tiendas PN") | ||
try { | ||
println("Ingrese el valor del producto 1") | ||
var prod1= readLine()!!.toDouble() | ||
println("Ingrese el valor del producto 2") | ||
var prod2= readLine()!!.toDouble() | ||
println("Ingrese el valor del producto 3") | ||
var prod3= readLine()!!.toDouble() | ||
var suma=prod1+prod2+prod3 | ||
println("¿El cliente desea redondear sus centavos? S/N") | ||
var respuesta= readLine() | ||
if( (respuesta=="S") or (respuesta=="s") ){ | ||
var totalMasRendondeo= ceil(suma) | ||
var redondeo=totalMasRendondeo-suma | ||
println("Gracias por redondear %.2f".format(redondeo)) | ||
}else{ | ||
println("Pinche cliente miserable") | ||
} | ||
}catch (e:Exception){ | ||
println("Pinche cajero tonto cometiste un error ${e} ") | ||
} | ||
|
||
|
||
|