HOME   ARTICLES   DIRECTORY   CONTACT   ABOUT 

Article Menu
superdotnet originals
Intro Lessons
Tips and Tricks
Data Access
Code-Behind/Controls
Quick Code
General ASP.NET
Windows Forms

All Articles
Reader Comments

Resource Options
Alphabetically
Directory

Hosts
.NET Hosts

More Resources
Namespace List
More MSDN Links
QuickStart Lists


Google



Calculating tax on an item
Article Categories: Quick Code
Rated: | Number Of Ratings 1 | Add Rating/View Ratings


A common task for developers is to have to calculate tax for an item depending upon a total price. This quick code example shows you how to convert from double to decimal data types and perform a simple tax calculation.

<% @Page Language="C#" %>

<script runat="server">


public void Page_Load(Object sender, EventArgs e){

double SubTotal = 12.00;
double doublepretax = 0.00;
doublepretax = SubTotal * .07;
decimal pretax = new decimal(doublepretax);
pretax = Decimal.Round(pretax,2);
doublepretax = System.Convert.ToDouble(pretax);

Response.Write(doublepretax);

}
</script>



Advertisement

Copyright superdotnet.com, all rights reserved. Original articles and site content may not be reproduced from our site without consent from superdotnet.com.
Privacy Policy and User Site Agreement