Using a Switch Statement


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Using a Switch Statement

  1. #1
    Join Date
    Jan 2006
    Posts
    5

    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;

  2. #2
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    You havent expalined your question very well?
    Can you word it any differently?

  3. #3
    Join Date
    Jan 2006
    Posts
    5
    Thanks for replying, got someone to explain it better to me so i got it done today. Thanks.

  4. #4
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    Quote Originally Posted by ShanD
    Thanks for replying, got someone to explain it better to me so i got it done today. Thanks.
    LOL..

    No problems, you hardly expalined your problem very well!
    Anyway, glad your good to go..

Similar Threads

  1. Switch Statement
    By stormswimmer in forum Java
    Replies: 7
    Last Post: 12-27-2005, 09:29 AM
  2. How do you loop a switch statement?
    By 72chevy in forum Java
    Replies: 3
    Last Post: 11-01-2005, 09:48 AM
  3. Use of Select Case or Switch Statement
    By Daryl Shockey in forum Database
    Replies: 2
    Last Post: 05-28-2002, 03:50 PM
  4. Access And SQL date statement
    By Saiful in forum VB Classic
    Replies: 7
    Last Post: 11-24-2000, 05:21 AM
  5. switch statement
    By James Lin in forum .NET
    Replies: 9
    Last Post: 08-15-2000, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center