Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _12345
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool result = false;
- while(!result){
- try
- {
- Console.WriteLine("Enter 6 a digit number e.g 123456");
- int n = int.Parse(Console.ReadLine());
- if (n.ToString().Length == 6)
- {
- if (int.Parse(n.ToString().Substring(0, (n.ToString().Length - 1))) % 7
- == int.Parse(n.ToString().Substring(n.ToString().Length - 1)))
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- result = true;
- }
- else { throw new Exception(); }
- }
- catch (Exception e)
- {
- Console.WriteLine("6 Digits only.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement