Advertisement
mzografski

DivideBy5and7

Mar 15th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class DivideBy7and5
  8. {
  9.     static void Main()
  10.     {
  11.         sbyte five = 5;
  12.         sbyte seven = 7;
  13.         uint intToCheck;
  14.         string divisible = "is divisible by 5 and 7";
  15.         string notDivisible = "is not divisible by 5 and 7";
  16.         Console.WriteLine("Please, enter a positive integer:");
  17.         while (!uint.TryParse(Console.ReadLine(), out intToCheck))
  18.         {
  19.             Console.WriteLine("Please, enter a correct integer");
  20.         }
  21.  
  22.         Console.WriteLine("{0} {1}", intToCheck, (((intToCheck % seven == 0) && (intToCheck % five == 0)) ? divisible : notDivisible));
  23.         Console.WriteLine("\nPress any key to exit.");
  24.         Console.ReadKey();
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement