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?
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?