Create a program whose Main() method prompts a user for length and width of a room in meter. Create a method that accepts the values and then computes the estimated cost of painting the room, 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. Return the estimated cost to the Main() method, and display it.
class Program
{
static double EstimateCost(double width, double length)
{
return (2.0 * (width + length) * 2.6 + 2.0 * (width * length)) * 20.0;
}
static void Main(string[] args)
{
Console.Write("Enter length: ");
double length = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter width: ");
double width = Convert.ToDouble(Console.ReadLine());
double cost = EstimateCost(width, length);
Console.Write("Estimated cost: " + cost);
Console.ReadKey(true);
}
}
Comments
Leave a comment