Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using TestInput;
- /*
- from Lesson 5 of C# console programming tutorial series at following URL:
- http://williammillerservices.com/windows-c-console-programming/
- demonstrates data input validation and multiplication of integers
- GitHub gist -> https://gist.github.com/kyrathasoft/ec0d45c9cfadc31736d6b0ce2efa3fce
- Pastebin.com -> https://pastebin.com/vaU09diD
- dependencies:
- -> https://gist.github.com/kyrathasoft/35357f7fee1c427693323286111e5e43
- compilation:
- (a) csc /out:mult.exe mult.cs tester1.cs
- (b) csc /r:tester1.dll mult.cs
- */
- namespace MultiplyIntegers {
- class Multiplier {
- static void Main(string[] args){
- string sData = String.Empty;
- int int1 = 0;
- int int2 = 0;
- bool valid = false;
- while(!valid){
- Console.Write("Please enter first valid integer: ");
- sData = Console.ReadLine();
- if(Tester.IsInteger(sData)){
- int1 = Int32.Parse(sData);
- valid = true;
- }
- }
- valid = false;
- while(!valid){
- Console.Write("Please enter a second valid integer: ");
- sData = Console.ReadLine();
- if(Tester.IsInteger(sData)){
- int2 = Int32.Parse(sData);
- valid = true;
- }
- }
- int product = int1 * int2;
- Console.WriteLine("{0} multiplied by {1} equals {2}.",
- int1.ToString(), int2.ToString(), product.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement