Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Aravind's teacher gives him an assignment on the topic array. He got two arrays as input, and in those he has to add the elements
Aravind's teacher gives him an assignment on the topic "array." He got two arrays as input, and in those he has to add the elements of both arrays and store them in a new array, and then only add the last digits of all elements from the third array and store them in a new variable and check if it is a prime number or not. Help Aravind complete his assignment using Java.
Requirements:
If both the array size is not the same, print "Both array size is different" then terminate the program.
If the size is less than or equal to zero, print is an invalid array size" then terminate the program.
If the elements entered in an array have a value less than zero, print is an invalid input" and then terminate the program.
Note:
In the Sample Input Output provided, the highlighted text in bold corresponds to the input given by the user, and the rest of the text represents the output.
Ensure to follow the objectoriented specifications provided in the question description.
Ensure to provide the names for classes, attributes, and methods as specified in the question description.
Adhere to the code template, if provided
Please do not use System.exit to terminate the program.
Sample inputOutput:
Enter the size of first array
Enter the array elements
Enter the size of second array
Enter the array elements
is not a prime number
Explanation
Array
Array
add the integers in the two arrays Array Array Array
Array
In a new variable only add last digits in a Array
Check for prime number
Hence is not a prime number
Sample inputoutput:
Enter the size of first array
Enter the array elements
Enter the size of second array
Enter the array elements
is a prime number
Explanation
Array
Array
add the integers in the two arrays Array Array Array
Array
In a new variable only add last digits in a Array
Check for prime number
Hence is a prime number
Sample inputOutput:
Enter the size of first array
is an invalid array size
Sample inputOutput:
Enter the size of first array
Enter the array elements
Enter the size of second array
is an invalid array size
Sample inputOutput:
Enter the size of first array
Enter the array elements
is an invalid input
Sample inputOutput:
Enter the size of first array
Enter the array elements
Enter the size of second array
Both array size is different
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