Advertisement
kyrathasoft

mult

Jul 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2. using TestInput;
  3. /*
  4. from Lesson 5 of C# console programming tutorial series at following URL:
  5. http://williammillerservices.com/windows-c-console-programming/
  6. demonstrates data input validation and multiplication of integers
  7. GitHub gist -> https://gist.github.com/kyrathasoft/ec0d45c9cfadc31736d6b0ce2efa3fce
  8. Pastebin.com -> https://pastebin.com/vaU09diD
  9. dependencies:
  10. -> https://gist.github.com/kyrathasoft/35357f7fee1c427693323286111e5e43
  11.  
  12. compilation:
  13. (a) csc /out:mult.exe mult.cs tester1.cs
  14. (b) csc /r:tester1.dll mult.cs
  15. */
  16. namespace MultiplyIntegers {
  17.    
  18.     class Multiplier {
  19.         static void Main(string[] args){
  20.             string sData = String.Empty;
  21.             int int1 = 0;
  22.             int int2 = 0;
  23.             bool valid = false;
  24.             while(!valid){
  25.                 Console.Write("Please enter first valid integer: ");
  26.                 sData = Console.ReadLine();
  27.                 if(Tester.IsInteger(sData)){
  28.                     int1 = Int32.Parse(sData);
  29.                     valid = true;
  30.                 }
  31.             }
  32.             valid = false;
  33.             while(!valid){
  34.                 Console.Write("Please enter a second valid integer: ");
  35.                 sData = Console.ReadLine();
  36.                 if(Tester.IsInteger(sData)){
  37.                     int2 = Int32.Parse(sData);
  38.                     valid = true;
  39.                 }
  40.             }
  41.             int product = int1 * int2;
  42.             Console.WriteLine("{0} multiplied by {1} equals {2}.",
  43.                 int1.ToString(), int2.ToString(), product.ToString());
  44.         }      
  45.     }  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement