daily pastebin goal
33%
SHARE
TWEET

Coding Conundrums 2.1: Crazy Times Tables

starbeamrainbowlabs Feb 18th, 2015 181 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. public class CrazyTables
  4. {
  5.         public static void Main(string[] args)
  6.         {
  7.                 if(args.Length != 1)
  8.                 {
  9.                         Console.WriteLine("Use it like this: ");
  10.                         Console.WriteLine("    CrayTables.exe <float>");
  11.                         Console.WriteLine("\n<float>: The number to use when generating the times table.");
  12.                         return;
  13.                 }
  14.  
  15.                 float number = float.Parse(args[0].Trim());
  16.                
  17.                 if(number == 0 || number == 1)
  18.                 {
  19.                         Console.WriteLine("Invalid times table number.");
  20.                         return;
  21.                 }
  22.                
  23.                 for(int i = 0; i < 12; i++)
  24.                 {
  25.                         Console.WriteLine("{0,2} times {1} is {2,2}", i + 1, number, (i + 1) * number);
  26.                 }
  27.         }
  28.  
  29.         public static bool ValidateInput(float number)
  30.         {
  31.                 if (number == 0 || number == 1)
  32.                         return false;
  33.                 else
  34.                         return true;
  35.         }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top