Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    6
    Rep Power
    0

    Default was not sure where to put this

    Hey guys,

    So I am somewhat new to programming and I feel that I have made some pretty quick advancements in my ability, I am having a problem with something that I am trying to do right now. I am trying to build a simple application that will have the user input a number and have a switch to output the info. I am not sure how to set the variable for the switch to be what the user inputs. Help?


    import java.util.Scanner;

    public class apples {
    public static void main(String args[]){

    Scanner bucky = new Scanner(System.in);



    switch (){

    case 1:
    System.out.println("first");
    break;
    case 2:
    System.out.println("second");
    break;
    case 3:
    System.out.println("third");
    break;
    case 4:
    System.out.println("fourth");
    break;
    case 5:
    System.out.println("fifth");
    break;
    case 6:
    System.out.println("sixth");
    break;
    default:
    System.out.println("fail");
    break;
    }

    }

    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    786
    Rep Power
    5

    Default Re: was not sure where to put this

    switch (bucky.nextInt()){

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •