Advertisement
Waliullah8328

Higest Number Two and Three (By Overloading)

Feb 2nd, 2021
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HigestNumber {
  6.     public static void FindMax(double x,double y)
  7.     {
  8.         if(x > y)
  9.         {
  10.             System.out.println("Maximum value of two number : "+x);
  11.         }
  12.  
  13.         else
  14.             {
  15.             System.out.println("Maximum value of two number: " + y);
  16.         }
  17.     }
  18.     public static void FindMax(double x, double y,double z)
  19.     {
  20.         if(x>y && x>z)
  21.         {
  22.             System.out.println("Maximum value of three number : "+x);
  23.         }
  24.         else if(y > x && y > z)
  25.         {
  26.             System.out.println("Maximum value of three number : "+y);
  27.         }
  28.         else
  29.         {
  30.             System.out.println("Maximum value of three number : "+z);
  31.         }
  32.     }
  33.  
  34.     public static void main(String[] args) {
  35.         Scanner input = new Scanner(System.in);
  36.  
  37.         double a,b,c;
  38.         System.out.print("Enter Your First Number: ");
  39.         a = input.nextDouble();
  40.  
  41.         System.out.print("Enter Your Second Number: ");
  42.         b = input.nextDouble();
  43.  
  44.         System.out.print("Enter Your Third Number: ");
  45.         c = input.nextDouble();
  46.         FindMax(a,b);
  47.         FindMax(a,b,c);
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement