Write a method that takes an array of type int and returns a double value. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a method that takes an array of type int and returns a double value. The method returns the average value of the positive elements of the taken array. Output Sample run int[] in = {1, 5, 7, -1, 0, 3, -15); double out = avgPositive(in); System.out.println("Result: " + out); int[] in = {1, 3, 3, 5, 15); double out = avgPositive(in); System.out.println("Result: " + out); Result: 4.0 Result: 5.4 Write a method that takes an array of type int and returns a double value. The method returns the average value of the positive elements of the taken array. Output Sample run int[] in = {1, 5, 7, -1, 0, 3, -15); double out = avgPositive(in); System.out.println("Result: " + out); int[] in = {1, 3, 3, 5, 15); double out = avgPositive(in); System.out.println("Result: " + out); Result: 4.0 Result: 5.4
Expert Answer:
Answer rating: 100% (QA)
Sure Heres a method that takes an array of type int and returns the average value of the posi... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
The following is a set of data from a sample of n = 11 items: a. Construct a scatter plot. b. Is there a relationship between X and Y? Explain. X: 7 5 8 3 6 0 2 4 9 5 8 Y: 1 5 4 9 8 0 6 2 7 5 4
-
Hodgkiss Mfg., Inc., is currently operating at only 79 percent of fixed asset capacity. Fixed assets are $392,700. Current sales are $510,000 and projected to grow to $716,582. How much in new fixed...
-
For your organization, or one you are familiar with, what are the observable artifacts, stated values, and taken-for-granted beliefs associated with your organization's culture? How would you...
-
Given the project network that follows, compute the early, late, and slack times for the project. Be sure to show the early finish and late start times on yournetwork. 20 15 25 10 10 Slack IS B
-
Give an example of useful Chi-Square Goodness-of-Fit Test. What problems might there be in getting the data for the test? How would you deal with the problems?
-
The Energy Information Administration reported the following sources of electricity in the United States in 2016: Source of Electricity Percentage...
-
The Framework for the Preparation and Presentation of Financial Statements identified seven user groups: investors, employees, lenders, suppliers and other trade creditors, customers, government and...
-
Colorado Mountain Mining paid $507,700 for the right to extract mineral assets from a 500,000-ton deposit. In addition to the purchase price, Colorado also paid a $600 filing fee, a $1,700 license...
-
How is the company evaluate the cost or revenue of the event base on profitability? the method is work well?
-
You are reviewing audit work papers containing a narrative description of the Tenney Corporations factory payroll sys-tem. A portion of the narrative is as follows: Factory employees punch time clock...
-
Imagine that a recession is forthcoming. How should the central bank of a developing nation influence the national currency? Directly or indirectly?
-
How do genome-wide association studies (GWAS) and polygenic risk scores contribute to our understanding of the genetic basis of complex traits and common diseases, and what are the challenges in...
-
6. Gate Appliances has a return on assets ratio of 8%. a. If the debt to total assets ratio is 40%, what is the return on equity? b. If the firm had no debt, what would the return on equity be?
-
On December 31, 2009, the stock of Alpha Associates was trading at $37.90. The following information is provided. Calculate Alpha's trailing and forward P/E ratio. Calculate the: a. trailing P/E...
-
A laptop is a common fixture in most Ontarian households. Indeed, most Ontarian households have laptops, and many of them have more than 1. A sample of 12 Ontarians households produced the following...
-
When Daysa graduates from college next week, he plans to buy a new car that costs $37,000. He will finance the entire purchase price with an automobile loan from his credit union. The loan, which...
-
It is important for all students, including students with disabilities, to have critical-thinking and problem-solving skills as tools to support them in the classroom with cross-curricular...
-
The sales department of P. Gillen Manufacturing Company has forecast sales in March to be 20,000 units. Additional information follows: Finished goods inventory, March 1 . . . . . . . . . . . . . . ....
-
If a stack is used instead of a queue for the topological sort algorithm in Section 9.2, does a different ordering result? Why might one data structure give a "better" answer?
-
Suppose a binomial queue of N = 2k 1 elements is built. Alternately perform M insert and deleteMin pairs. Clearly, each operation takes O(logN) time. Why does this not contradict the amortized bound...
-
If the recursive routine in Section 2.4 used to compute Fibonacci numbers is run for N = 50, is stack space likely to run out? Why or why not?
-
Leeds Architectural Consultants began operations on January 2. The following activity was recorded in the company's Work in Process account for the first month of operations: Leeds Architectural...
-
Estimated cost and operating data for three companies for the upcoming year follow: Predetermined overhead rates are computed using the following bases in the three companies: Required: 1. Compute...
-
Dillon Products manufactures various machined parts to customer specifications. The company uses a job-order costing system and applies overhead cost to jobs on the basis of machine-hours. At the...
Study smarter with the SolutionInn App