package sumadding;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.jar.Attributes.Name;
public class sumoftwonumber {
public static void main(String[] args) throws IOException {
InputStreamReader a = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(a);
System.out.println(" ------Enter First Number ------: ");
String frist= br.readLine();
int p = Integer.parseInt(frist);
System.out.println("-------Enter Second Number--------: ");
String second= br.readLine();
int q = Integer.parseInt(second);
int c = p+q;
System.out.println("-- Sum of two Number --: " + c);
}
}
In above program InputStreamReader and BufferedReader
inputstream- This is actually read from the keyboard and store in array list.
BufferReader read the next byte of data from the Inputstream reader.
In above Code, Frist I take input from the keyboard, user enter value from keyboard that value convert into integer,
I used Integer parsing for convert value from string to integer
same way it take second value from keyboard and store in string, using parse int I convert string into integer and after that i do addition of value and print on java console
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.jar.Attributes.Name;
public class sumoftwonumber {
public static void main(String[] args) throws IOException {
InputStreamReader a = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(a);
System.out.println(" ------Enter First Number ------: ");
String frist= br.readLine();
int p = Integer.parseInt(frist);
System.out.println("-------Enter Second Number--------: ");
String second= br.readLine();
int q = Integer.parseInt(second);
int c = p+q;
System.out.println("-- Sum of two Number --: " + c);
}
}
In above program InputStreamReader and BufferedReader
inputstream- This is actually read from the keyboard and store in array list.
BufferReader read the next byte of data from the Inputstream reader.
In above Code, Frist I take input from the keyboard, user enter value from keyboard that value convert into integer,
I used Integer parsing for convert value from string to integer
same way it take second value from keyboard and store in string, using parse int I convert string into integer and after that i do addition of value and print on java console
No comments
Post a Comment