copaz Posted September 29, 2003 Posted September 29, 2003 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; } Quote
aewarnick Posted September 29, 2003 Posted September 29, 2003 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. Quote C#
Administrators PlausiblyDamp Posted September 29, 2003 Administrators Posted September 29, 2003 change the last line to return (int) nondecimalanswer; Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.