Program to take Input from User

/*  Program to take Input from User */

import java.io.DataInputStream;

class Read
{
    public static void main(String args[])
    {
        int i;
        float f;
        DataInputStream in= new DataInputStream(System.in);
        try
        {
   
        System.out.println("Enter Integer number:");
        i=Integer.parseInt(in.readLine());

        System.out.println("Enter Float number:");
        f = Float.valueof(in.readLine()).floatvalue();
        }
        catch(Exception e)
        {

        }

        System.out.println("Integer Number is : "+i);
        System.out.println("Float Number is : "+f);
    }
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|