Results 1 to 3 of 3

Thread: User Input

  1. #1
    brmcdani is offline Member
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Default User Input

    Hey guys I am brand new to Java programming and I am going to get started on my first homework for one of my classes. I need to write an application that finds the smallest of several integers. Assume that the first value read in specifies the number of values to input from the user.

    I really don't know where to start with this but if someone can get me pointed in the right direction I can figure it out from there hopefully.

    Thanks!

  2. #2
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    5

    Default

    You should check out the Scanner class since you are new to Java. Scanner (Java 2 Platform SE 5.0)

    Example:

    Java Code:
    import java.util.Scanner;
    
    public class InputExample {
    	public static void main(String[] args) {
    		Scanner input = new Scanner(System.in);
    		String inputString;
    
    		System.out.print("Please type something: ");
    		inputString = input.next();
    
    		System.out.println("You just typed \"" + inputString + "\"");
             }
    }
    "Experience is what you get when you don't get what you want" (Dan Stanford)
    "Rise and rise again until lambs become lions" (Robin Hood)

  3. #3
    brmcdani is offline Member
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Default Sending input to array

    OK great start. Now if I wanted to insert the number inputted into an array that the user entered what would I do there? Here is what I have so far. Iam also going to add a while statement later that says while end is not entered by the user add the entry into the array. When "end" is entered though it will echo the numbers entered and also state the lowest number entered.

    Java Code:
    import java.util.Scanner;
    
    public class partOne {
    	
    	public static void main(String[] args) {
    		Scanner input = new Scanner(System.in);
    		int numbOne;
    
    		System.out.print("Please type a number or enter end to calculate lowest number: ");
    		numbOne = input.nextInt();
    
    		
    	}
    }

Similar Threads

  1. how to get input from User
    By Alvaro in forum New To Java
    Replies: 7
    Last Post: 01-16-2010, 12:02 AM
  2. To get time as input from user
    By yuvarani in forum New To Java
    Replies: 3
    Last Post: 12-16-2009, 01:19 PM
  3. User input- Pop Up Box
    By dedachi in forum AWT / Swing
    Replies: 3
    Last Post: 03-23-2009, 05:47 AM
  4. loop when there is no user-input
    By becky in forum New To Java
    Replies: 12
    Last Post: 02-02-2009, 11:02 PM
  5. cant take input from user
    By new_1 in forum New To Java
    Replies: 6
    Last Post: 12-25-2007, 08:38 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
  •