Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Added the solution for "Calculate the volume of a pyramid. [#920]" #922

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 54NPWF/R9tDQu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

class Program
{
static void Main()
{
double baseArea, height, volume;

Console.WriteLine("Enter the base area of the pyramid: ");
if (!double.TryParse(Console.ReadLine(), out baseArea))
{
Console.WriteLine("Invalid input. Please enter a valid number for the base area.");
return;
}

Console.WriteLine("Enter the height of the pyramid: ");
if (!double.TryParse(Console.ReadLine(), out height))
{
Console.WriteLine("Invalid input. Please enter a valid number for the height.");
return;
}

volume = (1.0 / 3) * baseArea * height;

Console.WriteLine($"The volume of the pyramid is: {volume}");
}
}