Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: help with switch statement

  1. #1
    Member
    Join Date
    Oct 2010
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default help with switch statement

    deleted...thanks
    Last edited by robertsbd; October 12th, 2010 at 12:48 PM. Reason: to delete


  2. #2
    Junior Member
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: help with switch statement

    Here i fixed it up for you so you can see where you had gone slightly off.

    import java.util.Scanner;
     
     
    public class Assign5_Roberts{
     
        public static void main(String[] args){
            Scanner in = new Scanner(System.in); //create a scanner
     
            System.out.println("Enter the item you are bidding on :");
            String itemName = in.nextLine(); 
     
            System.out.println("Enter your maximum bid: ");
            double maxBid = in.nextDouble();
     
            System.out.println("Enter  desired  delivery  method ( 0 for ground four day, 1 for ground express, 2 for air shipping ) :");
     
            int shippingMethod = in.nextInt(); //reads shiping type
     
            int shippingPrice = 0; // shipping price
     
            switch(shippingMethod) {
            	case 0: //no cost
            	break;
     
                case 1:  //express
                	shippingPrice = 5;
                break;
     
                case 2:  //air
                	shippingPrice = 15;
                break;
            }
     
            //invoice
            System.out.println("Invoice :");
            System.out.println("Item :" + itemName);
            System.out.println("Your Bid Price :" + maxBid);
            System.out.println("Total :" + (maxBid + shippingPrice));
     
     
        }
    }
    Last edited by bluurr; October 12th, 2010 at 12:33 PM.

  3. The Following User Says Thank You to bluurr For This Useful Post:

    robertsbd (October 12th, 2010)

  4. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: help with switch statement

    Robertsbd, please do not delete your posts/questions you received help from. Leaving the posts untouched allows others to potentially benefit from the problems you had and the solution(s) you received.

Similar Threads

  1. How to Use the Java switch statement
    By JavaPF in forum Java Programming Tutorials
    Replies: 6
    Last Post: April 18th, 2013, 05:19 PM
  2. Why Did You switch to Java?
    By Sisyphus in forum The Cafe
    Replies: 2
    Last Post: May 26th, 2010, 04:01 AM
  3. How to populate a switch statement with a linked list
    By macnasty in forum Collections and Generics
    Replies: 2
    Last Post: May 6th, 2010, 10:47 PM
  4. switch with Enums
    By chronoz13 in forum Loops & Control Statements
    Replies: 17
    Last Post: October 8th, 2009, 08:08 PM
  5. [SOLVED] Switch statement question
    By shikh_albelad in forum Loops & Control Statements
    Replies: 5
    Last Post: May 31st, 2009, 05:13 AM