public static void CreditCard() { while (true) { try { string cardNum = MiscMethods.GetInfo("Enter Card Number"); string cardExp = MiscMethods.GetInfo("Enter Card Exp (mm/yy)"); if (MiscMethods.IsOnlyDigits(cardNum) == false) { Console.WriteLine("Card Number is not all digits. Try again"); continue; } if (cardNum.Length != 16) { Console.WriteLine("Card number is not the right number of digits. Try again"); continue; } int month = int.Parse(cardExp.Substring(0, 2)); int year = int.Parse(cardExp.Substring(3, 2)); if (month > 12 || month <= 0 || year < int.Parse(DateTime.Now.ToString("yy"))) { Console.WriteLine("Incorrect date. Please try agian"); continue; } Console.WriteLine("Payment Accepted"); break; } catch { Console.WriteLine("Incorrect entry. Try again"); continue; } } }
public static void CheckPay() { while (true) { string ActNum = MiscMethods.GetInfo("Enter annount number"); string RoutNum = MiscMethods.GetInfo("Enter routing number"); if (MiscMethods.IsOnlyDigits(ActNum) == false || MiscMethods.IsOnlyDigits(RoutNum) == false) { Console.WriteLine("Incorrect entry. Try again"); continue; } if (RoutNum.Length != 9 || ActNum.Length >= 17) { Console.WriteLine("Incorrect entry. Try again"); continue; } Console.WriteLine("Payment Accepted"); break; } }