Create a C# program named PaintingEstimate whose Main() method prompts a user for length and width of a room in feet. Create a method that accepts the values and then computes the cost of painting the room, assuming the room is rectangular and has four full walls and 9-foot ceilings. The price of the job is $6 per square foot. Return the price to the Main() method, and display it.
Have a look at the below code. I have put comments wherever required for better understanding.
using System;
// create main class
class MainClass {
// create method to calculate painting cost
public static int PaintingEstimate(int length, int width){
return (2*(length+width)*9)*6;
}
public static void Main (string[] args) {
// take user input for length and width
Console.WriteLine ("Enter length: ");
int length = Convert.ToInt32(Console.ReadLine());
Console.WriteLine ("Enter width: ");
int width = Convert.ToInt32(Console.ReadLine());
// call the PaintingEstimate function and display on console
Console.WriteLine ("Cost is : "+PaintingEstimate(length,width));
}
}
Happy Learning!
Get Answers For Free
Most questions answered within 1 hours.