using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Decision_Structure_If_Statement_Ex02
{
class Program
{
static void Main(string[] args)
{
//Read x and y from user
//Compute sum = x + y
//if sum is less than 200, add 5 to x and subtract 10 from y
//otherwise subtract 15 from x and add 25 to y
//compute product
//if product is greater or equal to 1000 double x and half y
//otherwise triple y and subtract 50 from x,
//display x, y, sum, product
Console.Write("Enter value of x: ");
int x = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter value of y: ");
int y = Convert.ToInt32(Console.ReadLine());
int sum = x + y;
if (sum < 200)
{
x = x + 5;
y = y - 10;
}
else
{
x = x - 15;
y = y + 25;
}
Console.WriteLine("\n X = {0} Y = {1}", x, y);
Console.WriteLine("\nSum = {0}", sum);
int prod = x * y;
if (prod >= 1000)
{
x = x * 2;
y = y / 2;
}
else
{
x = x - 50;
y = y / 2;
}
Console.WriteLine("\nX = {0} Y = {1}", x, y);
Console.WriteLine("\nProduct = {0}", prod);
Console.ReadLine();
}
}
}
No comments:
Post a Comment