Answer to Question #329208 in C# for Siyanda

Question #329208

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.


1
Expert's answer
2022-04-15T16:34:09-0400
using System;

namespace calc_cost
{
    class Program
    {
        
        public static double calcCost(double length, double width)
        {
            double square_m;
            double cost;
            square_m = length * 2.6 + width * 2.6;
            cost = square_m * 20;
           
        return (cost);
        }

        public static void Main(string[] args)
        {
            double len, widt;
            Console.Write("Enter length: ");
            len = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter width: ");
            widt = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("The estimated cost = R{0}", calcCost(len, widt));

            Console.Write("\nPress any key to continue . . . ");
            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
New on Blog
APPROVED BY CLIENTS