[go: up one dir, main page]

Skip to content

Commit

Permalink
Redondeo a dos decimales, añadiendo control de errores
Browse files Browse the repository at this point in the history
  • Loading branch information
arkezam committed Feb 23, 2023
1 parent 80e0646 commit e2e1d60
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Binary file modified bin/Moneda.class
Binary file not shown.
Binary file modified bin/MonedaController.class
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Moneda.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public void setValorEnDolares(double valorEnDolares) {

public double convertirA(Moneda otraMoneda, double cantidad) {
double resultado = otraMoneda.ValorEnDolares / this.ValorEnDolares*cantidad;
return resultado;
return (double)Math.round(resultado*100)/100;
}
@Override
public String toString() {

return this.nombreAbreviado + " - " + this.nombre;

}
}
4 changes: 2 additions & 2 deletions src/MonedaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public class MonedaController implements Initializable {
void btnConvertir(ActionEvent event) {

try {
double numAConvertir = Math.round(Double.parseDouble(this.fieldDe.getText())*100)/100 ;
double numAConvertir = Double.parseDouble(this.fieldDe.getText()) ;

this.fieldA.setText(String.valueOf(
valorDe.convertirA(
valorA, numAConvertir)));
valorA, numAConvertir )));

} catch (RuntimeException e) {

Expand Down

0 comments on commit e2e1d60

Please sign in to comment.