Thursday, February 27, 2014

Calculating Perimeter and Area with Integer: (Wk-2), Jan 14, 14

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Computing_Area_Integer
{
    class Program
    {
        static void Main(string[] args)
        {
            //Request length and width from user
            //then compute perimeter, area and display all

            int length, width, perimeter, area;

            //Request length and width from the user
            Console.Write("Enter length: ");
            length = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter width: ");
            width = Convert.ToInt32(Console.ReadLine());

            perimeter = 2 * length + 2 * width;
            area = width * length;

            Console.WriteLine("\nPerimeter = {0} \nArea = {1}", perimeter, area);

            Console.ReadLine();           
        }
    }
}

No comments:

Post a Comment