Question: (50pts) Write a Java program A1p2.java with a public class A1p2 and no named packages that takes one command line argument assumed to be a

 (50pts) Write a Java program A1p2.java with a public class A1p2

(50pts) Write a Java program A1p2.java with a public class A1p2 and no named packages that takes one command line argument assumed to be a positive integer n. The program should prompt the user to input n integers from stdin (one per line) and store all of them in an array. After the program reads in the input integers, it should print the largest even input integer and the smallest odd input integer. You can assume that at least two integers will be input from stdin (i.e. n>=2 ) and at least one even integer and at least one odd integer will be input from stdin. (Can you imagine how your program should be revised if no even integer or no odd integer is input from stdin and your program should report this fact?) Although you don't have to, you can consider designing two additional methods besides main to implement the functionality. A sample run can look like the following (blue color means those are typed by the user): [kwangucomputer] [ /temp] \$ java A1p2 5 2 3 8 5 12 The largest even input integer is 12 . The smallest odd input integer is 3. If you run the program with standard input redirection, a sample run can look like the following (assuming the text file someNumbers.txt contains the 2,-3,8,5,12 on five separate lines): [kwangecomputer] [ /temp] \$ java A1p2 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!