jamesy23 — 2012-03-07T14:42:24-05:00 — #1
I have been given a task from school.
I've been asked to create a program that will keep track of how many books are sold and price of each book.
This program should allow me to enter each book name and price. It should also calculate the total price of the books and display it on screen.
Any help will be much appreciated!
paul_wilkins — 2012-03-07T17:10:31-05:00 — #2
We typically do not provide code for class assignments here, since the whole purpose of such assignments is for you to learn by making use of what your teacher has provided.
Your course tutor is best placed to give you what you need.
If there is anything specific that you would like to know more about though, we'll be happy to help.
jamesy23 — 2012-03-08T09:07:03-05:00 — #3
I understand, but it's not an assignment. Its more of something my former teacher has challenged me too!
I suppose the main thing I wanted to know was how I can build an array that will let me enter any number of books. For example I could enter 2 or 15.. I have no idea how to set that up.
paul_wilkins — 2012-03-08T15:02:30-05:00 — #4
Typically you would place the books array somewhere that it can be easily accessed. What used to be done is to make it a global array, but that's not a good practice these days after we learn that globals should be kept to an absolute minimum, so a good place to store the array is as a property on the form that you use to to enter the information.
var form = document.getElementById('bookSale');
form.books = ;
jamesy23 — 2012-03-09T05:48:22-05:00 — #5
The thing I don't quite understand is that after that say for example the user put in 3 books, how would I be able to give them the option to say that's all today because otherwise the prompt box would keep repeating wouldn't it?
paul_wilkins — 2012-03-09T05:55:23-05:00 — #6
It would be best to flowchart out all of the possible behaviour of someone using this. That way, once you fully know what is expected, you can craft together a working solution that meets those needs.