I wanna know if this exercise i did is like this or if i did wrong; the exercise is
"A person purchased a product to pay in 20 months. The first month he paid €10, the second €20, the third €40 and so on. Make a program to determine how much you must pay each month and the total amount you will pay after 20 months."
My code:
public class Ejercicio3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int a=5;
int i=1;
int suma=0;
while (i<=20) {
a=a*2;
System.out.println("Mes "+i+": "+a+" euros");
suma+=a;
i++;
}
System.out.println("El total es: "+suma+" euros");
}
}