The blog gives you idea of testing and automation testing example of selenium webdriver,SQl and Jmeter, you see the basic example of selenium web driver and get idea how to do automation testing,

Sum of two Number in Java when you enter through key board

 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



No comments

Post a Comment

Powered by Blogger.