salestax program

I'm currently making a salestax program for my overseas trip... it's for fun, but basically i want to be able to buy an item, say for $5, enter it into the program and it adds on 10% tax. So it will become $5.50, and then display the value, then ask me to enter another value for another item... then say i put $10 as my second value, and this $10 will also have 10% tax added to it... these two items are to accumulate and give me a value of $16.50 etc.... and if i was to make an error, say enter a 'z' or maybe -100 it would yield an error or close the application.

So in short pseudocode (not really, but you get the point).... something like this

ASK for 1st value
User enters 1st value
Add 10% tax to value
Display value
Prompt for second value
User enters second value
Add this value with previous and add 10% tax
Display value

... something like the above

Well, I know I will need a const salestax = 1.1

and cout << "Enter the first value" << endl;

and also a sum= sum + (sum*1.1)...? <--- not sure if that's right arithmetically but yeah.

Will I need to construct loops? or will I be fine doing it in a linear fashion?


Thanks.
Last edited on
I like your username. :)

I think you could use one loop to make the program repeat until you give it a value which lets it know that "oh boy, it's time to close" (a negative value?). That aside, check your arithmetic again. Plug in 5 into sum + (sum*1.1). It comes out to a bit more than 5.5, right?

Do you know about cin to get the user input?

Good luck!

-Albatross
OMG I got it working in less than 15 minutes O.o

But, whats the command to close an application?

cause right now I have:

if (num1<0)

cout << "Please close the application and try again" << endl;

i'd rather it do:

if (num1 < 0)

close <--- not sure what the same is lol

as for the cin... i just used cin >> num1

I am assuming I buy 10 items at the supermarktet though... if I buy 3 items then ill enter the value of the first 3, then 0 for the rest obviously
lol
Last edited on
oh lol, silly me, exit is just:

if (num1 < 0)

return 0;

LOL!

Well, got that bit covered too haha
Topic archived. No new replies allowed.