This is basic calculation of maximum and minimum number.  there are two number which we calculate which is max or which is min, as  a example we consider 24 and 25 then the max will be 25 and min will be 24.

Go to the series : https://browncodeit.blogspot.com/p/java-programs.html  

Source Code:  
  1. public class MaxMInimaDemo {
  2. public static void main(String[] args) {
  3. try (Scanner input = new Scanner(System.in)) {
  4. int num1,num2;
  5. System.out.print("Enter the number: ");
  6. num1 = input.nextInt();
  7. System.out.print("Enter the number: ");
  8. num2 = input.nextInt();
  9. if(num1 > num2) {
  10. System.out.print("maximum number is "+num1);
  11. }
  12. if(num1<num2){
  13. System.out.print("maximum number is "+num1);
  14. }
  15. }
  16. }
  17. }



Output:  

Enter the number: 15
Enter the number: 19
minimum number is 15

Enter the number: 59
Enter the number: 45
maximum number is 59

0 comments:

Post a Comment