[Solved] Java: I can add as period to another period?


Before begining your loop create three variables wich are totalAnios (totalYears), totalMeses (totalMonths) , totalDias (totalDays) and initialize them to 0.

   int totalAnios = 0;
   int totalMeses = 0;
   int totalDias = 0; 
   do {
     ....
   }

And before closing the loop (before while(…) ) you have to add the difference of years, months and days to the previous varibales you created ( totalAnios , totalMeses , totalDias ) and print the result.

do {
 ... 
 /* your calculation goes here */

   totalAnios += anios;
   totalMeses += meses;
   totalDias  += dias;

            System.out.println("total : " + totalAnios + " " + totalMeses + " " + totalDias);
} while (seguir != 'n');

Each time the user choose to stay in the loop, we sum the previous results and print the total.

By the way, next time don’t forget to format your code and put variables in english 😉 .

2

solved Java: I can add as period to another period?