using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Decision_Structure_If_Statement
{
class Program
{
static void Main(string[] args)
{
//Q: Request an integer value, then double it if it is less than 100
// or subtract 25 from it otherwise.
//Get user input
Console.Write("Enter an integer value: ");
int x = Convert.ToInt32(Console.ReadLine());
//Check if x is less than a 100
if (x < 100) // no semicolon in condition
{
x = x * 2;
}
else
{
//subtract 25 from x
x = x - 25;
}
//display the new value of x
Console.WriteLine("\n x = {0}", x);
//pause
Console.ReadLine();
}
}
}
No comments:
Post a Comment