Answer to Question #325955 in C# for Zarifa

Question #325955

Write a program to print the area of a rectangle by creating a class named 'Area' having two functions. First function named as 'setDim' takes the length and breadth of the rectangle as parameters and the second function named as 'getArea' returns the area of the rectangle. Length and breadth of the rectangle are entered through keyboard.( For C sharp with easy code)


1
Expert's answer
2022-04-12T16:19:05-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComputeAverageApp
{
    class ComputeAverageProgram
    {
        static void Main(string[] args)
        {

            Area area = new Area();
            Console.Write("Enter length: ");
            int length = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter breadth: ");
            int breadth = Convert.ToInt32(Console.ReadLine());
            area.setDim(length, breadth);
            Console.WriteLine("Area = {0}", area.getArea());

            Console.ReadLine();
        }

 
    }

    public class Area
    {
        int l;
        int b;

        public void setDim(int length, int breadth)
        {
            l = length;
            b = breadth;
        }

        public int getArea()
        {
            return l * b;
        }
    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS