Create a user defined method named calcCost() that accepts two double values as input (length and width), and then computes the estimated cost of painting a room (walls only, not ceiling), assuming the room is rectangular and has four full walls and the walls are 2.6 meter high. The rate for the painting job is R20 per square meter. Your method should return the estimated cost to the calling method. Create a program whose Main() method prompts a user for the length and the width of a room in meter, then calls calcCost to calculate the estimated cost. Once calculated, you should display the estimated cost.
internal class Program
{
static void Main()
{
Console.Write("Enter length : ");
double length = double.Parse(Console.ReadLine());
Console.Write("Enter width: ");
double width = double.Parse(Console.ReadLine());
calcCost(length, width);
Console.ReadKey();
}
static void calcCost(double length, double width)
{
double S = 2 * 2.6 * (length + width);
Console.WriteLine($"Estimated cost:{S * 20}");
}
}
Comments
Leave a comment