Created
September 18, 2012 19:09
-
-
Save jpetto/3745142 to your computer and use it in GitHub Desktop.
Adding Machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApplicationAddingMachine | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// declare some variables | |
int int1; | |
int int2; | |
int int3; | |
// ask the user for the first number | |
Console.WriteLine("Hey you - give me a number. Right now!"); | |
// capture the first number | |
int1 = int.Parse(Console.ReadLine()); | |
// ask for the second number | |
Console.WriteLine("Another! Another number!"); | |
// capture the second | |
int2 = int.Parse(Console.ReadLine()); | |
// ask for the second number | |
Console.WriteLine("Another! A third number!"); | |
// capture the second | |
int3 = int.Parse(Console.ReadLine()); | |
// calculate the sum of the three numbers | |
// declare a variable to hold the sum | |
int intSum = int1 + int2 + int3; | |
if (intSum <= 20 && intSum >= 0) | |
{ | |
Console.WriteLine("I don't remember what it was!"); | |
} | |
else | |
{ | |
Console.WriteLine("The sum is: " + intSum + "."); | |
} | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment