434,742 Members | 2,026 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,742 IT Pros & Developers. It's quick & easy.

Stuck on C++ program to calculate price and tax

 P: 63 I have to write a program that asks for a cost-per-item, number of items purchased, and a discount rate. Then it should calculate the total cost, tax due, and amount due. I have to use the formulas: total cost = number of items * cost-per-item total cost (discounted) = total cost - (discount rate * total cost) tax due = total cost * TAXRATE amount due = total cost + tax due I am going to put what I have so far. Any suggestions would be helpful. Also, how do I put the discount rate as a percentage? Expand|Select|Wrap|Line Numbers #include "stdafx.h" #include  #include  using namespace std;   int _tmain(int argc, _TCHAR* argv[]) {     const float TAXRATE = 0.06f;     double costPerItem, itemsPurchased, discountRate, totalCost, taxDue, totalCostDiscounted;       cout <<"\nEnter the cost-per-item: ";     cin >> costPerItem;     cout <<"\nEnter the number of items purchased: ";     cin >> itemsPurchased;     cout <<"\nEnter the discount rate: ";     cin >> discountRate;       totalCost = itemsPurchased * costPerItem;     totalCostDiscounted = totalCost - (discountRate * totalCost);     taxDue = totalCost * TAXRATE;     cout << setiosflags (ios::fixed)          << setiosflags (ios::showpoint)          << setprecision(2);       cout <<"\nThe total cost is: " << setw(4) << costPerItem*itemsPurchased  << endl;     cout <<"\nThe tax due is: " <
3 Replies

 Expert 100+ P: 1,764 I have to write a program that asks for a cost-per-item, number of items purchased, and a discount rate. Then it should calculate the total cost, tax due, and amount due. I have to use the formulas: total cost = number of items * cost-per-item total cost (discounted) = total cost - (discount rate * total cost) tax due = total cost * TAXRATE amount due = total cost + tax due I am going to put what I have so far. Any suggestions would be helpful. Also, how do I put the discount rate as a percentage? #include "stdafx.h" #include #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { const float TAXRATE = 0.06f; double costPerItem, itemsPurchased, discountRate, totalCost, taxDue, totalCostDiscounted; cout <<"\nEnter the cost-per-item: "; cin >> costPerItem; cout <<"\nEnter the number of items purchased: "; cin >> itemsPurchased; cout <<"\nEnter the discount rate: "; cin >> discountRate; totalCost = itemsPurchased * costPerItem; totalCostDiscounted = totalCost - (discountRate * totalCost); taxDue = totalCost * TAXRATE; cout << setiosflags (ios::fixed) << setiosflags (ios::showpoint) << setprecision(2); cout <<"\nThe total cost is: " << setw(4) << costPerItem*itemsPurchased << endl; cout <<"\nThe tax due is: " <

 P: 63 I am not really sure what a code tag is? I also figured out the percent question. Thanks for the help. Sep 11 '07 #3

 Expert 100+ P: 1,764 I am not really sure what a code tag is? I also figured out the percent question. Thanks for the help. You see # button in a message editor,well those arr code tags. Savage Sep 11 '07 #4 