Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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;

}

Posted

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.

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...