English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Can anyone help figure out what I am doing wrong? I'm trying to pass value and calculate cost
using System;

namespace Lab4
{

class Carpet

{


static void Main()

{
// Declaring Variables

double cost=0;
double price=0;

GetLength(length);
GetWidth(width);
GetPricePerSquareFeet(price);
CalcCostOfCarpet(length, width, price, cost);
DisplayCostOfCarpet(cost);


}


static double GetLength(double length)
{

string userin;
Console.WriteLine("Please enter Length:");
userin = Console.ReadLine();
length = Convert.ToDouble(userin);
return length;


} //end GetLength

static double GetWidth(double width)

{ // start GetWidth

string userin;
Console.WriteLine("Please enter Width:");
userin = Console.ReadLine();
width = Convert.ToDouble(userin);
return width;



}// end GetWidth

static double GetPricePerSquareFeet(double price)

{ // start GetPricePerYard

string userin;
Console.WriteLine("Please enter Price per square yard:");
userin = Console.ReadLine();
price = Convert.ToDouble(userin);
return price;

} // end GetPricePerSquareYard

static double CalcCostOfCarpet(double length, double width, double price, double cost)

{ // start calculate carpet



cost = (length * width) / 9 * price;
return cost;

}// end calculate carpet

static void DisplayCostOfCarpet(double cost)

{ // start DisplayCostOFCarpet

Console.WriteLine("Cost of Carpet{0:C}",cost);
Console.WriteLine("Press Return to Continue");
Console.ReadLine();


} // end DisplayCostOfCarpet


}

2006-12-04 13:10:24 · 2 answers · asked by Sad Mom 3 in Computers & Internet Programming & Design

2 answers

Not to be picky but you have too many spaces in your
code.
Also starting comments before or after a brace is a no-no ^_^

int fuc()
{//comment
do something...
}//comment

That's a little hard to read, even with the spaces.

int func()
{
//comment
do something
//comment
}

or the quick coder's way:

//comment
int func(){
do someting
}
//comment

Compact, neat, and very easy to read. It makes debugging
easier on so many levels.

Formatting ftw.
=)

2006-12-06 16:13:30 · answer #1 · answered by Hex 5 · 0 0

using System;

namespace Lab4
{
class Carpet
{
static void Main()
{
// Declaring Variables
double cost = 0;
double price = 0;

double length = GetLength();
double width = GetWidth();
GetPricePerSquareFeet(price);
CalcCostOfCarpet(length, width, price, cost);
DisplayCostOfCarpet(cost);
}

static double GetLength()
{
string userin;
Console.WriteLine("Please enter Length:");
userin = Console.ReadLine();
double length = Convert.ToDouble(userin);
return length;
} //end GetLength

static double GetWidth()
{ // start GetWidt
string userin;
Console.WriteLine("Please enter Width:");
userin = Console.ReadLine();
double width = Convert.ToDouble(userin);
return width;
}// end GetWidth

static double GetPricePerSquareFeet(double price)
{ // start GetPricePerYard
string userin;
Console.WriteLine("Please enter Price per square yard:");
userin = Console.ReadLine();
price = Convert.ToDouble(userin);
return price;
} // end GetPricePerSquareYard

static double CalcCostOfCarpet(double length, double width, double price, double cost)
{ // start calculate carpet
cost = (length * width) / 9 * price;
return cost;
}// end calculate carpet

static void DisplayCostOfCarpet(double cost)
{ // start DisplayCostOFCarpet
Console.WriteLine("Cost of Carpet{0:C}", cost);
Console.WriteLine("Press Return to Continue");
Console.ReadLine();
} // end DisplayCostOfCarpet
}
}

now grade my answer

2006-12-04 21:23:50 · answer #2 · answered by championForever 2 · 0 0

fedest.com, questions and answers