Computer Science, asked by 6godisgod, 5 months ago

A five digit integer is said to be friendly if the left most digit is divisible by 1, the left most 2-digits are divisible by 2, the left most 3-digits are divisible by 3, the left most 4-digits are divisible by 4 and the left most 5-digits are divisible by 5. Write a program to accept a number and perform the following: Check if the number is a 5-digit number, if not display an error message. If it is 5-digit number, then check if it is a friendly number or not based on the above description and display the output as friendly number, otherwise display the output as not a friendly number Sample input: Input number: 42325 Output: 42325 is a friendly number. 4 is divisible by 1, 42 is divisible by 2, 423 is divisible by 3, 4232 is divisible by 4, 42325 is divisible by 5.
WRITE A JAVA PROGRAM!

Answers

Answered by reetama99
0

Answer:

longggggggggg ggggggggggggg

Answered by Nikhil1611
5

Answer:

Plz mark it as brainliest if you liked the answer.

Explanation:

import java.util.*;

class Friendly_Number

{

   public static void main(String args[])

   {

       Scanner in = new Scanner (System.in);

       System.out.println("Enter the number");

       int n, a, b, c, d;

       n = in.nextInt();

       if (n >= 10000 && n <= 99999)

       {

           a = n / 10000;

           if (a%1==0)

           {

               b = n / 1000;

               if (b%2==0)

               {

                   c = n / 100;

                   if (c%3==0)

                   {

                       d = n / 10;

                       if (d%4==0)

                       {

                           if (n%5==0)

                           System.out.println("It is a Friendly number");

                           else

                           System.out.println("Not a Friendly number");

                       }

                       else

                       System.out.println("Not a Friendly number");

                   }

                   else

                   System.out.println("Not a Friendly number");

               }

               else

               System.out.println("Not a Friendly number");

           }

           else

           System.out.println("Not a Friendly number");

       }

       else

       System.out.println("Not a Friendly number");

   }

}

Similar questions