Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. (50pts) Write a Java program A1p2.java with a public class A1p2 and no named packages that takes one command line argument assumed to
2. (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 odd input integer and the smallest even input integer. You can assume that at least two integers will be input from stdin (ie, 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 would function if no even integer or no odd integer is input from stdin?) You can consider designing additional method(s) besides main to implement the functionality. A sample run can look like the following (blue color means those are typed by the user; note that n can be any number and 5 is just an example): [kwang@computer/temp]$ java Alp2 5 2 -3 8 co in 5 12 The largest odd input integer is 5. The smallest even input integer is 2. If you run the program with standard input redirection, a sample run can look like the following (assuming the text file someNumbers2.txt contains the 2,3,8,5,12 on five separate lines): [kwang@computer/temp] $ java Alp2 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started