All our Essay orders are Original, and are written from scratch. Try us today at 30% off

Java Program

CISC 1115 Fall 2021 Assignment 3
Write a complete Java program to do the following: the main program will call a series of methods to process a set of data. One method will read data into two arrays. A second method will print the values stored in an array. A third method will find the smallest of the values stored in an array. A fourth method will construct a new array from two existing arrays. A fifth method will compare the values in the two arrays. Use files for both input and output. Be sure to pass the file variable to any method that will need it.
1. The main program will read in n from the input file and call a method readData to read n items into two arrays (which the main program will call score1 and score2). All data values must be read from a file, and all values except the parameter value must be read in the method. Assume there are maximum 50 pairs of values to read.
2. The main program will call a method printArray twice to print the values stored in the two arrays. (Call the method once to print array score1 and once to print array score2.) Each time before the main program calls the printing method, it should print a heading saying what is being printed (for example, it could say “score1 array”). All output, including headings should go to a file.
3. For each array, the main program will call a method smallest which will find the smallest of the n values stored in an array. The main program will call the method once to find the smallest of the n values stored in the score1 array, and once to find the smallest of the n values stored in the score2 array. After each call, the main program will print the returned value, together with a relevant message.
4. The main program will call a method construct. The method will construct a new array (which the main program will call sumscore) from the two arrays score1 and score2. Then construct will call printarray to print the sumscore array. Either main or the method construct can print the heading for the sumscore array. The sumscore array will need to be sent back to the main program, either as a return value or as an array parameter.
5. The main program will call the method smallest again to find the smallest of the n values stored in the sumscore array. The main program will print this value.
6. The main program will call a method whatsHigher. This method will be used to compare the contents of the score1 and score2 arrays. The method will receive three parameters: two arrays (score1 and score2), and an integer n (giving the size of the two arrays). The method will compare the two arrays, element by element, to calculate in which array the corresponding value is higher. It will also count how many times the value in score1 is higher, and how many times in score2 is higher. It will print the counters, together with clear messages.
Here are the details of the methods.
A. The method readData will read the data into two arrays. The method will receive three parameters: an integer n, and two arrays which it calls nums1 and nums2. At the beginning, only the parameter n will have a value. The value of n will be used to control the action of the method, as described below. The method will read n sets of data. Each set of data should contain two integers; the first will be read into nums1, and second will be read into nums2. (The values stored in these parameters will remain when the method returns to the main program, and they can be used throughout the program.) For example, suppose the data set is the following:
3 18 13 21 42 66 66
The main program will read the value 3 into the variable n. In readData, the array nums1 will get the values 18, 21, and 66, and the array nums2 will get the values 13, 42, 66. Note that you cannot read down the column of values – the two values you read will come from the same line, and you will place the values into the two arrays.
B The method printArray will receive two parameters, an integer lim, and an array called vals. It will print the lim values stored in the array vals, all on one line, with spaces between the values.
C. The method smallest will receive two parameters, an integer num and an array called arr. It will find and return the smallest of the first num elements of the arr array.
D. The method construct will receive four parameters: an integer k, and three arrays called old1, old2, and sumarr. The method will construct the first k elements of the sumarr array fromt the first k elements of the old1 and old2 arrays, as follows. Each element of sumarr will be equal to the sum of the corresponding elements of old1 and old2. For example, sumarr[0] will be old1[0]+old2[0], sumarr[1] will be old1[1] + old2[1] and so on. (You are using parallel arrays.)
E. The method whatsHigher will receive three parameters: two arrays (called score1 and score2), and an integer n (giving the size of the two arrays). The method will compare the two arrays, element by element, to calculate in which array the value is higher. For each array element, the method will print which array has the higher value (or if the two values are equal). The method should print each of the values, the array it is from and the relationship. For example, for the data above, the method should print something like the following messages:
In position 0 the higher value is in array score1: 18 is higher than 13 in position 1 the higher value is in array score2: 42 is higher than 21 in position 2 the value is the same in both arrays: 66
In addition, the method counts how many times the value from score1 is larger, how many times the value from score2 is larger, and how many time the values in the two arrays are equal. Use local variables for the counters. Print these values before returning to the main method.
DATA: Read the data from a file which is to be prepared in advance (be sure to submit the file). Use a parameter value of 10-15, but write a program which will work for any size arrays up to 50 or so. Make sure that the smallest element does not occur in the first or the last position of an array. Make sure that the smallest element does not occur at the same position in each array. Make sure that the two arrays have the same value in at least one position. Try to make sure that the value make the counters printed at the end have 3 different values.
SAMPLE INPUT AND OUTPUT: (make yours larger)
6 95 94 98 98 42 45 43 18 64 54 83 79
Sample output for this data file (your order and words might be slightly different):
There are 6 values in each array. The score1 array: 95 98 42 43 64 83 The score2 array: 94 98 45 18 54 79
The smallest value in score1 is 42 The smallest value in score2 is 18
The sumscore array: 189 196 87 61 118 162
The smallest value in sumscore is 61
In position 0, array score1 is larger: 95 is greater than 94 In position 1, the two arrays have the same value: 98 …
Array score1 was larger 4 time(s) Array score2 was larger 1 time(s) The two arrays were equal 1 time(s)
The post Java Program first appeared on Assignment writing service.




They look cool and trustworthy enough to me. I gather they made discounts as their prices are quite affordable if...

Great Job

Great job! Those were you, guys, who made my coursework perfect in time according to all my requirements. I will...

No Complaints So far Guys

Yeah …I really like all the discounts that they offer, the prices are very flexible. Plus they have different promotions...

Best Service

The book review I asked for is so amazing! Endless thanks to your team for completing my review and for...

Comes through every time

I have used this website for many times, and each time they found perfect writers for me and they produce...

Mh! not bad…

The worst part ever was to find my deadline postponed for 1 hour ! They couldn`t finish the essay within...

CLICK HERE  To order your paper

About Scholarfront Essay writing service

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for upto 20% off in their first Order. Our payment method is safe and secure.

 CLICK HERE to Order Your Assignment



Let your paper be done by an expert

Custom Essay Writing Service

Our custom essay writing service has already gained a positive reputation in this business field. Understandably so, all custom papers produced by our academic writers are individually crafted from scratch and written according to all your instructions and requirements. We offer Havard, APA, MLA, or Chicago style papers in more than 70 disciplines. With our writing service, you can get quality custom essays, as well as a dissertation, a research paper, or term papers for an affordable price. Any paper will be written on time for a cheap price.

Professional Essay writing service

When professional help in completing any kind of homework is all you need, is the right place to get it. We guarantee you help in all kinds of academia, including essay, coursework, research, or term paper help etc., it is no problem for us. With our cheap essay writing service, you can be sure to get credible academic aid for a reasonable price, as the name of our website suggests. For years, we have been providing online custom writing assistance to students from countries all over the world, including the United States, Canada, the United Kingdom, Australia, Italy, New Zealand, China, and Japan.