What am i doing wrong? it seems easy, but i am having troubles. i am trying to c
ID: 3721589 • Letter: W
Question
What am i doing wrong? it seems easy, but i am having troubles. i am trying to convert to a decimal format.
using System;
namespace PaintEst
{
public class PaintingEstimate
{
public static void Main(String[] args)
{
decimal price;
price = (decimal)GetCost();
Console.WriteLine(" At $6 per sqft, the price to paint this room is {1}.", price.ToString("c"));
}
public static double GetCost()
decimal length;
decimal width;
decimal totalSquareFeet;
{
Console.Write("What is the Lenth of Wall to Paint? ");
length = Convert.ToDecimal(Console.ReadLine());
Console.Write("What is the Width of Wall to Paint? ");
width = Convert.ToDecimal(Console.ReadLine());
decimal height = 9;
decimaltotalSurfaceArea;
totalSurfaceArea = ((length + width) * 2) * height;
double costPerFt = 6;
double totalCost = costPerFt * (decimal)totalSurfaceArea;
Console.WriteLine(" Total Surface Area is {0}", totalSurfaceArea);
return (double)totalCost;
}
}
}
Explanation / Answer
using System.IO;
using System;
namespace PaintEst
{
public class PaintingEstimate
{
public static void Main(String[] args)
{
decimal price;
price =GetCost();
Console.WriteLine(" At $6 per sqft, the price to paint this room is {0}.", price.ToString("c"));
}
public static decimal GetCost()
{
decimal length;
decimal width;
decimal totalSquareFeet;
Console.Write("What is the Lenth of Wall to Paint? ");
length = Convert.ToDecimal(Console.ReadLine());
Console.Write("What is the Width of Wall to Paint? ");
width = Convert.ToDecimal(Console.ReadLine());
decimal height = 9;
decimal totalSurfaceArea = ((length + width) * 2) * height;
decimal costPerFt = 6;
decimal totalCost = costPerFt * totalSurfaceArea;
Console.WriteLine(" Total Surface Area is {0}", totalSurfaceArea);
return totalCost;
}
}
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.