English, asked by pranathireddy365, 7 months ago

An string or character array containing five Mobile
numbers is provided
Verify these five mobile numbers and identify
valid as well as invalid numbers.
Any mobile number less than or greater than 10
digits or any characters is considered as invalid.
Write a code which will generate report on count
of total number of invalid mobile numbers. try to code this question in java​

Answers

Answered by saxenaajay10
0

Answer:

074322732612211111000

Answered by dreamrob
0

Program:

import java.util.*;

public class MyClass

{

   public static void main(String args[])

   {

       Scanner Sc = new Scanner(System.in);

       String S[] = new String[5];

       System.out.println("Enter 5 Numbers : ");

       for(int i = 0 ; i < 5 ; i++)

       {

           S[i] = Sc.nextLine();

       }

       int count = 0;

       for(int i = 0 ; i < 5 ; i++)

       {

           if(S[i].length() == 10)

           {

               int flag = 0;

               for(int j = 0 ; j < 10 ; j++)

               {

                   if(S[i].charAt(j)<48 || S[i].charAt(j)>57)

                   {

                       flag = 1;

                   }

               }

               if(flag == 1)

               {

                   count++;

               }

           }

           else

           {

               count++;

           }

       }

       System.out.println("Total invalid numbers : " + count);

   }

}

Output:

Enter 5 Numbers :

1234567890

99887uhy76

998876

9988776655

99009988776655

Total invalid numbers : 3

Similar questions