Computer Science, asked by griya1109, 9 months ago

Q2.Write a program to input n numbers on command line argument and calculate maximum of them

Answers

Answered by aj478610
0

Answer:

the program to input of maximum to them

Answered by GouravSharmaGuru
3

Answer:

package com.gouravsharma;    // package name can be different

import java.util.Arrays;              

public class Main

{

 public static void main(String[] args)

  {  if (args.length == 0)

      {

         System.out.println("\n Gourav Atleast ek integer to enter kro.");

         System.exit(0);

       }

      else{

               Arrays.sort(args);

               System.out.println("\n Maximum number is : " + args[args.length-1]);

              }

   }

}

Explanation :

simple,  just enter the n number input values on command line argument then run this program.

This program basically convert unsorted values into sorted array , yaani sort krne ke baad jo array ka last element hoga vo hi maximum number hoga.

I hope you understand clearly.

Advise : Never stop learning and just try to solve the same problem in another way. Because a problem can be solved in many ways.

Similar questions