Simple java programme to display the minimum of two numbers

 PROGRAM:             

public class Solution {                                                                                                                                                                                                       
public static void main(String[] args) throws Exception {

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

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

int a=Integer.parseInt(br.readLine());                                                                               

int b=Integer.parseInt(br.readLine());                                                                                                                                                   
if((a <b)||(a==b))                
System.out.println(a);                                                                   

else if(a>b)

System.out.println(b);

}

}

OUTPUT:

Enter two numbers

33 25

25

ALTERATION: 

 To display the maximum of two numbers replace all <(less than symbol) with > (greater than symbol) and vice versa.

Comments

Popular posts from this blog

Python program to sum up the Salary when the Name and Age matches with subsequent rows.

Typescript basics