G
Guest
I am trying to add dollar amounts together and add sales tax but everthing
after the decimal point is being cut off in the dollar amounts. Here is my
code:
if (Adults != "")
{
AdultTotal = int.Parse(Adults) * Convert.ToInt32(myReader["RateAdult"]);
ttlAdults.Text = Adults;
}
if (Children != "")
{
ChildTotal = int.Parse(Children) * Convert.ToInt32(myReader["RateChild"]);
ttlChildren.Text = Children;
}
double Tax = (AdultTotal + ChildTotal ) * (.06);
double TotalCost = (AdultTotal + ChildTotal );
txtTotal.Text = TotalCost.ToString() + " " + Tax.ToString();
The Adults and Children variables are ints and contain a quantity amount
from a form. The rate is grabbed from the database this is where the problem
is everything after the decimal in the rates are being chopped off.
I know I am probably using the wrong types. What is correct way to do this?
Thank you very much, Justin.
after the decimal point is being cut off in the dollar amounts. Here is my
code:
if (Adults != "")
{
AdultTotal = int.Parse(Adults) * Convert.ToInt32(myReader["RateAdult"]);
ttlAdults.Text = Adults;
}
if (Children != "")
{
ChildTotal = int.Parse(Children) * Convert.ToInt32(myReader["RateChild"]);
ttlChildren.Text = Children;
}
double Tax = (AdultTotal + ChildTotal ) * (.06);
double TotalCost = (AdultTotal + ChildTotal );
txtTotal.Text = TotalCost.ToString() + " " + Tax.ToString();
The Adults and Children variables are ints and contain a quantity amount
from a form. The rate is grabbed from the database this is where the problem
is everything after the decimal in the rates are being chopped off.
I know I am probably using the wrong types. What is correct way to do this?
Thank you very much, Justin.