This document discusses a Java programming assignment submitted by a student. It includes their name, UID, class details, and a question asking to write a program that takes command line arguments and finds the maximum number.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
22 views3 pages
1 As Java Q5
This document discusses a Java programming assignment submitted by a student. It includes their name, UID, class details, and a question asking to write a program that takes command line arguments and finds the maximum number.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3
JAVA PROGRAMMING
ASSIGNMENT 1 NAME: SHUBHAM KUMAR SINGH UID: 20BCS7312 CLASS & SECTION: 20BCS32 (A) SUBJECT: JAVA PROGRAMMING SEMESTER: THIRD
QUESTION 2:
Write a program to input n numbers on command line argument and
calculate maximum of them. </CODE> class Max { public static void main(String[] args) { if (args.length == 0) { System.out.println("You must enter at least 1 integer. Please try again."); System.exit(0); } findMax(args);
} static void findMax(String[]
strValues) { int numMax = numbers[0]; //int maxValue=0; for (int i = 0; i < strValues.length; i++) { int numbers = Integer.parseInt(strValues[i]); if(numbers[i] > numMax){ numMax = numbers[i]; System.out.println(numMax);