Skip to content

Instantly share code, notes, and snippets.

@edolopez
Last active December 26, 2015 08:08
Show Gist options
  • Save edolopez/7119703 to your computer and use it in GitHub Desktop.
Save edolopez/7119703 to your computer and use it in GitHub Desktop.
Example Input/Output in Java
import java.io.*;
public class Age {
public static void main(String [] args) throws IOException {
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader systemIn = new BufferedReader(inStream);
String my_name, greeting, myAge, variable;
greeting = "Hello ";
// Your input name, via terminal
System.out.println("Please introduce your name");
my_name = systemIn.readLine();
// Your input age
System.out.println("Please introduce your age");
myAge = systemIn.readLine();
// Casting = Casteo
numeric_age = Double.parseDouble(myAge);
// numeric_age = Integer.parseInt(myAge);
// Concatenation
// Output
System.out.println(greeting + my_name + "! \nYour age is: " + myAge);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment