When I tried to debug it's not giving me the result that is on the textbook. I tried to figure out what is wrong with it for like an hour and i cant figure it out. can someone help me what is wrong with this? thank you.
using System;
namespace HW3
{
public class CarpetWithClassMethods
{
public static void Main()
{
double roomwidth;
double roomlength;
double pricePerSqYard;
double noOfSquareYards;
DisplayInstructions();
roomlength = GetDimension("length");
roomwidth = GetDimension("width");
pricePerSqYard = GetPrice();
noOfSquareYards = DetermineSquareYards(roomwidth, roomlength);
DisplayResults(noOfSquareYards, pricePerSqYard);
}
public static void DisplayInstructions()
{
Console.WriteLine("This program will determine how much carpet to purchase. ");
Console.WriteLine("You will be asked to enter the size of the room ");
Console.WriteLine("and the price of the carpet, in price per square yards.");
Console.WriteLine();
}
public static double GetDimension(string side)
{
string inputValue;
int feet, inches;
Console.Write("Enter the {0} in feet: ", side);
inputValue = Console.ReadLine();
feet = int.Parse(inputValue);
Console.Write("Enter the {0} in inches: ", side);
inputValue = Console.ReadLine();
inches = int.Parse(inputValue);
return (feet + (double)inches / 12);
}
public static double GetPrice()
{
string inputValue;
double price;
Console.Write("Enter the price per Square Yard: ");
inputValue = Console.ReadLine();
price = double.Parse(inputValue);
return price;
}
public static double DetermineSquareYards(double width, double length)
{
const int SQ_FT_PER_SQ_YARD = 9;
double noOfSquareYards;
noOfSquareYards = length * width / SQ_FT_PER_SQ_YARD;
return noOfSquareYards;
}
public static double DeterminePrice(double noOfSquareYards, double pricePerSquareYard)
{
return (pricePerSquareYard * noOfSquareYards);
}
public static void DisplayResults(double noOfSquareYards, double pricePerSquareYard)
{
Console.WriteLine();
Console.WriteLine("Square Yarads needed: {0,N2}", noOfSquareYards);
Console.WriteLine("Total Cost at {0;C} ", pricePerSquareYard);
Console.WriteLine(" per Square Yard: {0:C} ", DeterminePrice(noOfSquareYards, pricePerSquareYard));
}
}
}

New Topic/Question
Reply
MultiQuote







|