Ok in this chapter i will share how to find the bigger number with use Java Input Output Buffered Reader check this code :
import java.io.*;
public class BiggerNum{
public static void main(String[] args){
BufferedReader inputnum = new BufferedReader(new InputStreamReader(System.in));
String i="";
int temp=0;
for(int j=1; j<=3; j++){
System.out.print("Input to"+j+" : ");
try {
i = inputnum.readLine();
}catch(IOException e){
System.out.println("data error!!!");
}
int input= Integer.parseInt(i);
if (temp<input){
temp=input;
}
}
System.out.println("Bigger number is : "+temp);
}
}
import java.io.*;
That code will import java Input Output used Buffered Reader and Stream Reader
BufferedReader inputnum = new BufferedReader(new InputStreamReader(System.in));
That code will defined inputnum for variable BufferedReader and will be use for input state
int input= Integer.parseInt(i);
That code will defined input is new variable and "Integer.parseInt" used for convert String variable to integer variable.
- if statement will selection if input bigger than temp so temp content is same with input content.
- See ya in the next chapter... :D ^_^v
No comments:
Post a Comment