i have to write a program for a class i'm in to caclulate the price of carpet in square yards when the user inputs length and width in feet, but i keep getting the error message "use of unassiged local variable 'variableName'". How might I fix this???
Here's the code
using System;
using System.Collections.Generic;
using System.Text;
namespace Yards
{
class Program
{
static void Main(string[] args)
{
double carpetPrice = 2.99;
double squareFeet, squareYards, finalPrice;
int length, width, value = 9;
string lengthStr, widthStr, carpetPriceStr;
squareFeet = length * width;
squareYards = squareFeet / value;
finalPrice = squareYards * carpetPrice;
Console.WriteLine("Enter the length of the room.");
lengthStr = Console.ReadLine();
length = Convert.ToInt32(lengthStr);
Console.WriteLine("Enter the width of the room.");
widthStr = Console.ReadLine();
width = Convert.ToInt32(widthStr);
Console.WriteLine("Enter carpet price per square yard.");
carpetPriceStr = Console.ReadLine();
carpetPrice = Convert.ToDouble(carpetPriceStr);
Console.WriteLine("The total price is {0}", finalPrice.ToString("C"));
Console.ReadLine();
}
}
}