I have a question about decimals and doubles. I know that you cannot use any mathematical operands between decimals and doubles...but, for example I created a program for a store that is holding a sale and offering a 10% discount. I was told that for the most part you want to declare decimal variables when dealing with money but, would i be able to declare the 10% as a decimal? how would i? i did read about casting it from double to decimal but obviously there could be a loss of data.
I have a second question, this is more of a curious question. I have purchased "starting out with visual C# 2012". and there is a question (3.42, for those who have the book) that asks "write a programming statement that declares a named constant for a 10 percent discount" and the answer is "const double discount = 0.9;" now i know it just says to write a statement so it could include more mathematical operations but, is there a format string that rounds this up to 10%?
نویسنده : استخدام کار بازدید : 0 تاريخ : پنجشنبه
1396 ساعت: 13:58