Computer Science, asked by mcjuniadiqbal, 6 months ago

Write a single statement to add up the first digit and the last digit of a three digit number stored in the

variable named x and assign the sum to y.​

Answers

Answered by 28CowansNoah
0

Answer . 35.  the answer is 35

Explanation:

Y equals 15 right X equals 20 so 20x15 equals.?

Answered by saransrini03
0

public class FirstLastDigitSum {

   public static int sumFirstAndLastDigit(int number)//to add first and last

//digits of a given interger

   {

       int firstdigit=0;

       int lastdigit=0;

       if(number>=0 && number<=9)

       {

           return number+number;

       }

       else if(number>9)

       {

           lastdigit=number%10;

           while(number>0)

           {

               number/=10;

               if(number<=9 & number>=0){

                   firstdigit=number;

               }

           }

           return firstdigit+lastdigit;

       }

       else

       return -1;

   }

   public static void main(String[] args)

   {

       System.out.println(sumFirstAndLastDigit(121));

   }

}

Similar questions