+ 2
Credit Card Validation
This one seemed to be easy at first, but i found myself stuck with this coad coach) could anyone help me out? https://www.sololearn.com/coach/96?ref=app
2 Respostas
+ 2
The first big problem you have is in converting of input into integer. Better will be to code: 
b[i] = Convert.ToInt32(Convert.ToString(a[i]));
The second are the length of the for loops. Only the first for loop counts till end of your array.
0
namespace Sololearn
{
    class Program
    {   
  static void Main(string[] args)
        {
        //1— turned string to int[]+ made a reverse
  string a =Console.ReadLine();
  if (a.Length==16) 
  {          
  int [] b = new int [16];
  int count =0;
  for (int i=0;i<=15;i++)
  {
b[i] = (int)Char.GetNumericValue(a[15-i]); 
  }
  //2 - doubled all the odd numbers    
  for (int j=0;j<15;j+=2)
  {
  b[j]*=2;    
  }
 for (int m =0;m<15;m++) 
 {
  if (b[m]>9) // made a sum with a 9 substraction
  {
   b[m]-=9;
   count+=b[m];   
  }
  else
  {
  count+=b[m];
  }
  }   
  // sum validation and String Length validation
  if (count%10==0)
  {
 Console.WriteLine("valid");   
  }
  else
  {
 Console.WriteLine("not valid");    
  }
  }
  else
  {
  Console.WriteLine("not valid");    
  }  
        }
    }
}



