Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Using a Switch Statement

Hi im new to Java and looking for some guidance.
Im trying to write a program that reads a series of pairs of numbers for a product and the quantity sold for the day. I think i have to have to ask the user 7 times for each product and then add the product up for the week. I have to use a switch statement so ive just started on that part so far, not sure if it is right. So i have 5 products and their prices. Is this the best place to start. Thanks.


products
int price = 0;

switch (products) {

case 1: price = $2
break;

case 2: price = $4
break;

case 3: price = $6
break;

case 4: price = $8
break;

case 5: price = $10
break;
[975 byte] By [ShanD] at [2007-11-11 7:53:29]
# 1 Re: Using a Switch Statement
You havent expalined your question very well?
Can you word it any differently?
Code_Nerd at 2007-11-11 22:37:03 >
# 2 Re: Using a Switch Statement
Thanks for replying, got someone to explain it better to me so i got it done today. Thanks. :WAVE:
ShanD at 2007-11-11 22:38:03 >
# 3 Re: Using a Switch Statement
Thanks for replying, got someone to explain it better to me so i got it done today. Thanks. :WAVE:

LOL..

No problems, you hardly expalined your problem very well!
Anyway, glad your good to go.. ;)
Code_Nerd at 2007-11-11 22:39:12 >