Skip to content

Instantly share code, notes, and snippets.

@santiago-tapia
Created January 28, 2018 20:44
Show Gist options
  • Save santiago-tapia/99e2e5a0de86d27d65b2454f7ffdd628 to your computer and use it in GitHub Desktop.
Save santiago-tapia/99e2e5a0de86d27d65b2454f7ffdd628 to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main
{
public static void main(String[] args) {
// Valores iniciales
double saldo, interes, cuota;
Scanner sc = new Scanner(System.in);
saldo = sc.nextDouble();
interes = sc.nextDouble();
cuota = sc.nextDouble();
// Creamos la lista (vacía)
LinkedList<Double> lista = new LinkedList<>();
// El bucle que añade elementos a la lista
while ( saldo > 0 ) {
lista.add( saldo );
double pago_interes = interes * saldo / 100; // interes en %
double amortizacion = cuota - pago_interes;
saldo = saldo - amortizacion;
}
for ( double cuenta : lista ) {
System.out.println("El saldo es: " + cuenta);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment