Wednesday, 11 November 2020

Java Program to find the sum of 2 numbers entered by the user using InputStreamReader Class

import java.io.*; 

public class Sum_IOStream

{

public static void main(String args[]) throws IOException

{

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

int N1,N2,Sum;

System.out.println("Enter 2 Numbers");

N1=Integer.parseInt(in.readLine());

N2=Integer.parseInt(in.readLine());

Sum=N1+N2;

System.out.println("The Sum of "+N1+" and "+N2+" is "+Sum);

}

}



No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...