Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Student ID: Except the classes mentioned below, no other classes / packages are allowed to solve the following problems. Create a public class named Yourlastname

Student ID:
Except the classes mentioned below, no other classes/packages are allowed to solve the following problems.
Create a public class named Yourlastname_Yourfirstname_final(5 pts).
import java.util.Arrays;
import java.util.Sacanner;
import java.lang.IllegalStateException;
import
java.io.*;
import java.lang.Comparable;
import java.lang.IndexOutOfBoundsException;
Write a static method named problem1 that accepts two arrays of integer values. Find and return the union of two arrays. Each element must be unique in the union array. You may assume each array contains unique elements. Return the result. (15 pts)
Test case: array1 is {1,2,3,4,5}, array 2 is {4,5,6,7,8}, return {1,2,3,4,5,6,7,8}.
Write a static method named problem 2 that keeps asking the user for string literals. Throw IllegalStateException if the entered string literal is empty. When the user enters "stop", the loop should be terminated. Capitalize each word (the first letter must be upper case and the rest of letters must be lower case). Join all the words together and separate any two words by using "#".(15 pts)
Test case: if the entered words are "apple", "BANANA", "oRANGE", "stop", return "Apple#Banana#Orange".
Write a static method named problem 3 that accepts an array of string literals. Remove all the strings with length greater than 5. Return the result. (10 pts)
Test case: array is "python", "java", "javascript", "c++"}, return "java", "c++"}.
Write a static method named problem4 that receives a path of a text file. Read data from the given file. Handle the IOException and the FileNotFoundException. Calculate the sum of all the digits then write the result back to the file. (10 pts)
Test case: the text in the test.txt file is:
abc123cda345
cc34
56
Write 36 to the text file (because 1+2+3+3+4+5+3+4+5+6=36).
image text in transcribed

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

6. Conclude with the same strength as in the introduction

Answered: 1 week ago

Question

7. Prepare an effective outline

Answered: 1 week ago