I am writing a program to serve as a point of sale device for a restauraunt(not for real, final project in class). Anyway, I have some choice selections in my program, such as an appetizer. I need to be able to assign each appetizer a numerical value, to be used in calculation of a sub total, and total. I am not finding anything giving a good example, in my text, nor in some other books I have. I have been scowering the net, but I guess I am not looking for the right thing, or have found it and just dont know it. If anyone has any Idea how I do this I would appreciate it.
I'm not entirely clear on your question. What does this numerical value represent? Is it the price for the item? If so, you should use the name "price" instead of "a2". In fact, "a2" is a poor variable name since it does not describe what the variable means. You should pick a more descriptive name so that you (and others) can understand your code more easily.
With that said, can you be more specific about what you need help with? Like I said earlier, I don't understand what this numerical value is for. Also, do you have a class that represents individual items? This might be helpful, but I'm not entirely sure since you haven't posted enough of your code yet in order for me to get a clear picture of what is happening.
the numerical value will be the price of the item. I had chosen a2, becaue that was meant to represent the second appetizer choice. I do not have a clas s that represents each Item. There are just items added to a choice menu.
here is the part of my code that I am trying to get the numerical values to show up in.
Joined: May 21, 2005
Well, this here has me worried. If I am reading this correct, it is telling me that there is no way to take a string value of a choice, and when selected have that return a double, or integer.
So, I am still workin on my problem. It has been over 24 hours, I am not sure If I should give up on it, The only problem is I fear I have tried to do something that can not be done. Right now I have tried going with a combobox, just do not have the knowledge to complete it, aslo tried checkbox to the same conclusion. I am regretting the fact that the course is online, and my teacher is in Germany. It is nice to have the freedom, but it seems every other post of a student I read through, they have a much better understanding of the language. Scotch is kicking in now.
My latest idea has been an if statement.
such as stating if the ChoiceItem Chips_and_Salsa is selected double appetizerPrice = 2.50;
if ChoiceItem Queso is selected double appetizerPrice = 3.50;\
and so on.
This has not returned favorable results, well no results at all, I am getting incompatible types with code the likes of:
well I think I should sleep on this until tommorrow, I should have 15 or so hours to work on it.