Input

Try the following code:

  1. Open Ready to Program.
  2. Open the IBIO.java file in the Unit 1 folder of the I://. Save it to the Unit 1 folder in your own space on the G://. (Or download it)
  3. Open a new program in ready to program. Save it to the Unit 1 folder in your own space on the G://. Cut and paste in the following code:
  public class FirstInput
  {
   public static void main (String args [])
   {
     new FirstInput ();
   }
   public FirstInput ()
   {
   	System.out.println ("W E L C O M E");
   	System.out.println ("");
   	int a = IBIO.inputInt ("Input a number >> ");
   	System.out.println ("You have entered " + a + ".");
   	System.out.println ("");
   	String name = IBIO.inputString ("Type your name >> ");
   	System.out.println ("The name you entered is " + name + ".");
   }
 }
 


This code has a couple of new things in it.

Declare a variable to hold input int age;
Get input age = IBIO.inputInt("Enter your age: ");
Print out a variable (Note the + sign between the string and the variable) System.out.println("Your age is" +age);