Create a program that will accept two numbers from a user and display their sum. As we know that the readLine() function reads the entered text as string,whereas calculations can be made only on numeric values(having data type int,float,double)only. Hence, convert the entered string values into numeric values before making the calculation.

public class UsingStream
    public static void main(String ags[])throws IOException
	   int num1;
	   int num2;
	   int num;
	   InputStreamReader objectISR=new InputStreamReader(;
	   BufferedReader objectBR=new BufferedReader(objectISR);
	   System.out.printIn("Enter First Number");
	   String n1=objectBR.readLine();
	   System.out.printIn("Enter Second Number");
	   String n2=objectBR.readLine();
	   System.out.printIn("Sum of"+num1+"and"+num2+"is :"+sum);

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Show Buttons
Hide Buttons