Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

image text in transcribed

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions