[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

sales tax

Posted on 2003-03-29
5
Medium Priority
?
546 Views
Last Modified: 2010-04-15
I am not a programmer. I am looking to find the source code to calculate the
sales tax of number of items enter. Any help would be wonderful. The source code should be in C in Windows.

Input: # of items, price of each item, sales tax% of your state(will us 5%), amount tendered

Output: total and change returned if any

Thanks!
0
Comment
Question by:ladiet
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
adg080898 earned 100 total points
ID: 8230408
I doubt anyone will sit down and write the whole program for you.

In any case, it is very simple to calculate (here is some pseudocode):

--------

subtot = 0
for each item {
    subtot += qty * unitprice
}

tax = subtot * taxrate
total = subtot + tax

change = amtpaid - total

--------

Where taxrate is 0.05 for 5% tax
0
 

Assisted Solution

by:bvbb
bvbb earned 100 total points
ID: 8230765
Here's a function that will do this. It assumes money amounts are stored as cents so they can be integers. If you're truly not a programmer, this won't be all you need, as it must be tied into the rest of your application.

int totalwithtax(int itemcount, int prices[], float rate, int tender, int totaltax, int change);
int totalwithtax(//calculate order total with sales tax
     int itemcount,     //number of items
     int prices[],          //array of item prices (in cents)
     float rate,               //tax rate as a fraction (for example, .0525 for 5.25%)
     int tender,               //amount tendered (in cents)
     int totaltax,          //used to return total sales tax to calling program (in cents)
     int change,               //used to return change owed to calling program (in cents)
     //function return value: total amount of order (in cents)
){
     int total=0;
     for ( i = 0; i < itemcount ; i++ ){
          total+=prices[i];
     }
     totaltax=int(total*rate+.5);
     total+=totaltax;
     change=tender-total;
     return total;
}
0
 
LVL 8

Expert Comment

by:adg080898
ID: 8233700
If you have Excel or other spreadsheet software then I would recommend that you use it to calculate your totals. It would be a lot less work than making a program from srcatch to do it.

In Excel you could record a few macros and assign them to buttons to clear the page and a field to enter amounts. Simple formulas would calculate the total, tax, and change.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10187251
Nothing has happened on this question in more than 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between adg and bvbb.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question