Answer to Question #326396 in C# for Chinara

Question #326396

Write a program to print the volume of a box by creating a class named 'Volume' with an initialization list to initialize its length, breadth and height. (just to make you familiar with initialization lists) c#

1
Expert's answer
2022-04-10T05:24:17-0400
using System;
class Volume
{
	public double length { get; set; }
	public double breadth { get; set; }
	public double height { get; set; }
	public void CalculateVolume()
    {
		Console.WriteLine($"Volume: {length * breadth * height}");
    }
}
class Program
{
	static void Main(String[] args)
	{
		Volume vol = new Volume()
		{
			length = 2,
			breadth = 3,
			height = 4
		};
		vol.CalculateVolume();
	}
}

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