int and double

copaz

Newcomer
Joined
Sep 24, 2003
Messages
4
Location
lyburg
I am having trouble with using an int and a double in an equation.

public static void TaxAmount(out double convertprice,out int nondecimaltax)
{
string inputPrice;
string inputTaxrate;


Console.WriteLine("Please input the Price");
inputPrice=Console.ReadLine();
convertprice=Convert.ToDouble(inputPrice);

Console.WriteLine("Please input the Taxrate");
inputTaxrate=Console.ReadLine();
nondecimaltax=Convert.ToInt32(inputTaxrate);
}
public static int CalculateTaxAmount(double convertprice,int nondecimaltax)
{
double nondecimalanswer;
nondecimalanswer=convertprice*nondecimaltax;
return nondecimalanswer;
}
 
Here you are multiplying a double by an int

public static int CalculateTaxAmount(double convertprice,int nondecimaltax)
{
double nondecimalanswer;
nondecimalanswer=convertprice*nondecimaltax;
return nondecimalanswer;
}

You need to either convert the nondecimalanswer to an int or return a double.

You did not give me any error info, so I could not decide exacly what your problem was. But this is definately one.
 
Back
Top