Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MaximumApp {
- public static void main(String[] args) {
- int a,
- b,
- c,
- d;
- a = -10;
- b = 100;
- c = 20;
- d = 521;
- int newMaxNumber = max(a, b);
- System.out.println(newMaxNumber);
- newMaxNumber = max(a, b, c);
- System.out.println(newMaxNumber);
- newMaxNumber = max(a, b, c, d);
- System.out.println(newMaxNumber);
- }
- private static int max(int a, int b) {
- /**
- * This method describes the determination of the maximum
- * value among the variables passed to the method parameters.
- *
- * @param a variable of type Integer, it can be positive and negative values
- * @param b variable of type Integer, it can be positive and negative values
- * @return variable of type Integer, maximum value of 2 parameters
- */
- return (a > b) ? a : b;
- }
- private static int max(int a, int b, int c) {
- /**
- * This method describes the determination of the maximum
- * value among the variables passed to the method parameters.
- *
- * @param a variable of type Integer, it can be positive and negative values
- * @param b variable of type Integer, it can be positive and negative values
- * @param c variable of type Integer, it can be positive and negative values
- * @return variable of type Integer, maximum value of 3 parameters
- */
- int newCheckNumb;
- newCheckNumb = max(a, b);
- return (newCheckNumb > c) ? newCheckNumb : c;
- }
- private static int max(int a, int b, int c, int d) {
- /**
- * This method describes the determination of the maximum
- * value among the variables passed to the method parameters.
- *
- * @param a variable of type Integer, it can be positive and negative values
- * @param b variable of type Integer, it can be positive and negative values
- * @param c variable of type Integer, it can be positive and negative values
- * @param d variable of type Integer, it can be positive and negative values
- * @return variable of type Integer, maximum value of 4 parameters
- */
- int newCheckNumb;
- newCheckNumb = max(a, b, c);
- return (newCheckNumb > d) ? newCheckNumb : d;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement