title: How can I sum the second digit to the last digit in an integer on java?
body: <p>Can you tell me how Can I fix this program to make the "sumSecTolastD" operator does the following:<br>
  <em>1-</em> sum the second digit to the last digit in an integer (for example: 324 + 564 + 9876 = 29 since (2 + 4) + (6 + 4) + (8 + 7 + 6) = 29).<br>
  <em>2-</em> if I insert one digit only, it still able to give me the sum ( for example: 1 + 3 + 4 = 8).</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import java.util.*;
  public class Pr66{
        public static void main(String[] args){
        Scanner scan = new Scanner (System.in);
        int num1;
        int num2;
        int num3;
        int sumLastD;
        int sumSecTolastD;
  
        System.out.print("Please write an integer: ");
           num1 = scan.nextInt();
  
        System.out.print("Please write an integer: ");
           num2 = scan.nextInt();
  
        System.out.print("Please write an integer: ");
           num3 = scan.nextInt();
  
        sumLastD = num1 % 10 + num2 % 10 + num3 % 10;
          System.out.println();
          System.out.println("- LastDigitSum: " + num1 % 10 + " + " + num2 % 10 + " + " + num3 % 10 + " = " + sumLastD);
          
        if (sumLastD % 2 == 0)
          System.out.println("- LastDigitSum: is an even integer");
        else
          System.out.println("- LastDigitSum: is an odd integer");
  
          System.out.println();
  
        sumSecTolastD = (num1/10) % 10 + (num2/10) % 10 + (num3/10) % 10;
          System.out.println("- SecToLastSum: " + (num1/10) % 10 + " + " + (num2/10) % 10 + " + " + (num3/10) % 10 + " = " + sumSecTolastD);
                  
        if (sumSecTolastD % 2 == 0)
          System.out.println("- SecToLastSum: is an even integer");
        else
         System.out.println("- SecToLastSum: is an odd integer");
         
          }//main
  }//Pr66</code></pre>
  </div>
  </div>
  </p>