Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JUPUS) Write a complete Java program, including comments, to do the following: a) Write a method called read Data which will receive one parameters, a

image text in transcribed
JUPUS) Write a complete Java program, including comments, to do the following: a) Write a method called read Data which will receive one parameters, a one-dimensional array of integers called numbers. The method will read a parameter value which it calls num, and then read num lines of data, each of which contains a single integer. The data values are stored into the array numbers, the method returns the value of num and the filled-in array b) Write a method called countSixes which will receive two parameters, an integer num and an array of integers called numbers. The method will count and return how many of the first num elements of array numbers are equal to six and return this value. (For example, if the array currently holds values 55 6 7-5 6 81 with num = 6, then there are 2 values of six in the array.). c) Write a method called subtract3from All which will subtract 3 from each element stored in the array. (The method receives the usual parameters - an integer num giving the size of the array and an array of integers called numbers). d) Write a main program which will call these functions as follows: 1) First, the main program will call readData to read a set of data containing mynum elements into an array of integers which the main program calls mynumbers. You can assume that the array has no more than 50 elements. Note that mynum is a variable whose value is determined by the method readData. The original values read into the array are to be printed by the main program, Hi Then, it will call the method countSixes to find how many of the first mynum elements of mynumbers are six. This value is to be printed by the main program. Then, the main program will call subtract3fromAll to modify the mynumbers array. The new values of the array should be printed by the main program. iv) Finally, the main program will call count Sixes a second time to determine how many of the first mynum elements of the modified mynumbers array are six. Once again, this value is to be printed by the main program. Make sure that each method receives the right parameters with the right data types. Make sure that your methods do not use non-local variables. Note: Use either an external file or interactive data entry. Be consistent and include all appropriate statements (e.g., prompts, reset, etc.). Indicate which method you are using within a comment

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_2

Step: 3

blur-text-image_3

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

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions