Tuesday, 27 August 2013

Input Value By user at runtime

JAVA Program that take value user at run time mean at the time of console interaction.

import java.util.Scanner;

class Program
{
public static void main(String []args)
{
Scanner input=new Scanner(System.in);
int number=input.nextInt();
float fNumber=input.nextFloat();
String value=input.nextLine(); //get value string at console

System.out.println(number);  //Print the integer value
System.out.println(fNumber); //Print the Float Number
System.out.println(value); //Print the String value
}
}



INPUT
4
5.5
yasir

OUTPUT
4
5.5
yasir



What is Console?
This answer  only for those who don't know about the word console or Shell and I  only give the answer in pictorial



No comments:

Post a Comment