Computer Science, asked by nityaagarwal2007, 4 months ago

write a program to input two numbers and print the highest using buffer reader​

Answers

Answered by kamalrajatjoshi94
3

Answer:

Program:-

//Program using Buffered Reader

import java.io.*;

public class Main

{

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

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

int a,b;

System.out.println("Enter the numbers");

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

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

System.out.println("The greater number="+Math.max(a,b));

}

}

  • The first photo is the program
  • The second photo is the output

Note:In place of Math.max you may use if and else statement just use this:

import java.io.*;

public class Main

{

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

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

int a,b;

System.out.println("Enter the numbers");

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

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

if(a>b)

{

System.out.println("The greater number="+a);

}

else

{

System.out.println("The greater number="+b);

}

}

}

Attachments:
Similar questions