Answer to Question #199409 in C# for Nkhululeko Chabala

Question #199409

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.


1
Expert's answer
2021-05-27T19:09:41-0400
   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);
        }
    }

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
APPROVED BY CLIENTS