Question
(50pts) Write a Java program A2p1.java with a public class A2p1 and no named packages that takes one command line argument assumed to be a
(50pts) Write a Java program A2p1.java with a public class A2p1 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 strings from stdin (one per line) and store all of them in an array. After the program reads in the input strings, it should print the longest input strings. Note that if there are more than one longest string they should all be printed. Two sample runs can look like the following (blue color means those are typed by the user):
[kwang@computer][~/temp]$ java A2p1 4
(User Input)2xx
8abc
5xyz
12
(output)The longest input strings are:
8abc
5xyz
[kwang@computer][~/temp]$ java A2p1 3
(User Input)a2
b3c
7
(Output)The longest input strings are:
b3c
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