Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am doing a c++ program and need help with adding the tax, total, subtotal, and fees. Tax is 7%. The example output look like this
Invoice
Introduction to C++
Tony Gaddis
ISBN: 000345664
Price: $25.00
Quantity: 6
Subtotal: $150.00
Tax: $10.50
Fees: $2
Total: $162.50

What I have tried:

I have tried everything. I have the title, author, ISBN, price and quantity but can't figure out the rest.
Posted
Updated 6-Nov-19 17:57pm
Comments
Mohibur Rashid 18-Sep-19 1:42am    
We do not trust your word right now. You may not trying everything. Show us proof that you are trying everything.
CPallini 18-Sep-19 3:13am    
Show us something about your attempts, might be we are able to fix it.
Stefan_Lang 18-Sep-19 4:16am    
Tell us what, exactly, is not working, and show us the code you have right now. The problem may be anything from formatting, to calculation, to correct use of the output stream.

Since this is clearly a task meant to help you learn something, it is important that you figure out as much as possible yourself. Otherwise there is no point in 'solving' it at all, or taking the C++ class for that matter.

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Start by converting the Price to a floating point value - at the moment it's probably a string. Do the same for the quantity and the tax rate: 7% is 0.07.
Then work out your total:
price without taxes = price per item * quantity
total = fees + price without taxes + (price without taxes * tax rate)

Give it a try - it may be easier than you think!
 
Share this answer
 
Comments
CPallini 18-Sep-19 3:14am    
5.
#include <iostream>
#include <string>

using namespace std;

int main()

{
	
	string title, author;
	double price;
	long isbn;
	int quantity;
	
	cout << "Introduction to C++ ";
	getline(cin, title);
	cout << "Tony Gaddis ";
	getline(cin, author);
	cout << "ISBN: 000345664 ";
	cin >> isbn;

	cout << "Price: $25.00" << endl;
	cout << "Quality: 6" << endl;
	cout << "Subtotal: $150.00" << endl;
	cout << "Tax: " << endl;
	cout << "Total: " << endl;
	
	double tax = 0.07*price;
	int fee = 0;
	if (quantity == 7)
		fee = 4;
	else if (quantity > 7)
		fee = (quantity - 5) * 2;
	
	

	system("pause");
	return 0;

}
 
Share this answer
 
Comments
Stefan_Lang 7-Nov-19 2:25am    
1. Please don't dig up old questions. Most of the time this won't help anyone, but it will clutter the list of current, more important questions.

2. Please do not post full solutions to questions that are clearly homework, contest or other kind of training material. The whole point of such tasks is learning to program, and by posting a full solution you're anihilating that purpose. These kind of questions require guidance, not solutions.
Richard MacCutchan 7-Nov-19 4:09am    
2. Especially when the "solution" is such poor code.
Richard Deeming 8-Nov-19 15:02pm    
This solution was posted by the OP. :)
Stefan_Lang 11-Nov-19 4:54am    
Ok, let's add:
3. Don't post additional info on your question as a solution. ;-p

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900