/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 402 - Problem 1: Absolute Value (a) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static int AbsoluteValue(int number) { if (number < 0) return (-1 * number); return number; } static void Main(string[] args) { int x, y; Console.Write("Please enter a number: "); x = int.Parse(Console.ReadLine()); y = AbsoluteValue(x); Console.WriteLine("\n\nThe absolute value of {0} is {1}.", x, y); Console.ReadKey(); } } }