Question

DO THIS IN C#.Design and implement a program (name it ComputeAreas) that defines four methods as...

DO THIS IN C#.Design and implement a program (name it ComputeAreas) that defines four methods as follows: Method squareArea (double side) returns the area of a square. Method rectangleArea (double width, double length) returns the area of a rectangle. Method circleArea (double radius) returns the area of a circle. Method triangleArea (double base, double height) returns the area of a triangle. In the main method, test all methods with different input value read from the user. Document your code and properly label the input prompts and the outputs as shown below. Sample run: Square side: 5.1 Square area: 26.01 Rectangle width: 4.0 Rectangle length: 5.5 Rectangle area: 22.0 Circle radius: 2.5 Circle area: 19.625 Triangle base: 6.4 Triangle height: 3.6 Triangle area: 11.52

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# the code in C# for computing areas

using System;
  
class ComputeAreas //Calculate the Average marks and percentage for students
{
static public void Main(string[] args)
{
double length, width, radius, side, Base,hieght,area;
//create an object of class ComputeAreas
ComputeAreas obj = new ComputeAreas();
  
Console.WriteLine("Enter the side of a square");
side = float.Parse(Console.ReadLine());
area=obj.squareArea(side);
Console.WriteLine("Area of Square is :{0}", area);
  
//Rectangle Area
Console.WriteLine("Enter the Length for Rectangle");
length = float.Parse(Console.ReadLine());
Console.WriteLine("Enter the breadth for Rectangle");
width = float.Parse(Console.ReadLine());
area=obj.rectangleArea(width,length);
Console.WriteLine("Area of rectangle is :{0}", area);
  
  
Console.WriteLine("Enter the Radius of the Circle");
radius = float.Parse(Console.ReadLine());
area=obj.circleArea(radius);
Console.WriteLine("Area of Circle is :{0}", area);
  
Console.WriteLine("Enter the Base of Triangle ");
Base = float.Parse(Console.ReadLine());
Console.WriteLine("Enter the Height of Triangle ");
hieght = float.Parse(Console.ReadLine());
area=obj.triangleArea(Base,hieght);
Console.WriteLine("Area of Triangle is :{0}", area);
}
public double squareArea (double side)
{
double area;
area=side*side;
return area;
}
public double rectangleArea (double width, double length)
{
double area;
area=length*width;
return area;
}

public double circleArea (double radius)
{
double area;
area=3.14*radius*radius;
return area;
}

public double triangleArea (double Base, double hieght)
{
double area;
area=Base*hieght/2;
return area;
}
}

Add a comment
Know the answer?
Add Answer to:
DO THIS IN C#.Design and implement a program (name it ComputeAreas) that defines four methods as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT