Write a method called rainfall() that takes a Scanner as a parameter, representing an input source....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a method called rainfall() that takes a Scanner as a parameter, representing an input source. The input source contains data representing rainfall amounts on different days of the week. Each amount is represented as a positive integer, and the end of the list of numbers is represented by a negative number, which signals the end of useful input. Write your method so that it continually reads numbers from the input scanner, and then computes and returns the average of the positive numbers. The method should return zero if there are no positive integers provided. You may not use any container (array, list, etc.) in your answer. (Hint: recall that the Scanner class provides hasNextInt () and nextInt () methods for dealing with integer input values). Examples: rainfall (input ("1 2 3 -1")) -> 2 rainfall (input("3 4 -10")) -> 3.5 rainfall (input("1 2 3 -1 ")) -> 2 1 public double rainfall (Scanner input) 2 { 3 4} 5 Write a method called rainfall() that takes a Scanner as a parameter, representing an input source. The input source contains data representing rainfall amounts on different days of the week. Each amount is represented as a positive integer, and the end of the list of numbers is represented by a negative number, which signals the end of useful input. Write your method so that it continually reads numbers from the input scanner, and then computes and returns the average of the positive numbers. The method should return zero if there are no positive integers provided. You may not use any container (array, list, etc.) in your answer. (Hint: recall that the Scanner class provides hasNextInt () and nextInt () methods for dealing with integer input values). Examples: rainfall (input ("1 2 3 -1")) -> 2 rainfall (input("3 4 -10")) -> 3.5 rainfall (input("1 2 3 -1 ")) -> 2 1 public double rainfall (Scanner input) 2 { 3 4} 5
Expert Answer:
Related Book For
Statistics The Exploration & Analysis Of Data
ISBN: 9780840058010
7th Edition
Authors: Roxy Peck, Jay L. Devore
Posted Date:
Students also viewed these programming questions
-
Write an alternative definition that is tail-recursive (iterative) and makes use of accumulator variables. [10 marks] Explain why your alternative definition executes more efficiently. [3 marks] 1...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
The combined sewer system in city ABC is comprised of two parallel interceptors referred to as "North" and "South" lines. The southern line is connected to a newly built wastewater treatment plant....
-
When the magnetic field changes in a coil of wire, voltage in each loop of the coil is induced. Will voltage be induced in a loop if the source of the magnetic field is the coil itself?
-
On May 31, Martys Ice Cream Shop sells gift cards for $5,000. Customers redeem $1,200 in June, $2,100 in July, and $1,400 in August. Martys experience is that any unredeemed gift cards as of August...
-
The velocity ratio of third system of pulleys is 2 n 1. True or False
-
Borealis Manufacturing has just completed a major change in its quality control (QC) process. Previously, Products had been reviewed by QC inspectors at the end of each major process, and the...
-
When I am looking for an experimental Modulus of elasticity in a reinforced concrete Beam, where do I start my .1% offset on my load over the deformation graph? Is it .001 or .1% of the total...
-
1) Use the base case assumptions as well as the information presented in the case to build a four-year discounted cash flow model for Advanced Seal given a 50% cannibalization rate for the Premium...
-
Which of the following statements regarding multicountry competition is false? O O O One of the features of multicountry competition is that buyers in different countries are attracted to different...
-
Consider one on a very large scale. The United States' financial markets, namely the stock and bond markets, are widely considered among the most, or perhaps the most, transparent and corruption free...
-
Screw engagement length is 4.7mm And I am applying 200Ncm torque on M4 screw from top and screwdriver length is 150 mm. Q1- how much torque will transfer on M4 standoff? M4 Screw material (STEEL...
-
3. Radio signal from a radio station is transmitted by a wave of Student No (Last Digit) 4&5 Wave Equation s(t) = 45 cos (8 10 + + 3 sin (2 10t)) Assume R= 10. Calculate the frequency deviation,...
-
Create a new Tableau Workbook Save the new Workbook as Assignment 2 Go To Data Source Load Sample - Superstore.xls Drag Orders, People, and Returns to the Data Source Worksheet Go to Sheet 1 and...
-
What are the coordinates of the orthocenter of XYZ with vertices at - X(-3, 3).Y(1, 3).a Z(-3, 0)? and
-
Solve the inequalities than graph them y < -r +2 v > e - 2
-
Find an equation of the given line. Slope is -2; x-intercept is -2
-
Fumonisins are environmental toxins produced by a type of mold and have been found in corn and in products made from raw corn. The Center for Food Safety and Applied Nutrition provided...
-
Researchers at the University of Houston decided to test the hypothesis that restaurant servers who squat to the level of their customers would receive a larger tip (Effect of Server Posture on...
-
The authors of the paper Evaluating Existing Movement Hypotheses in Linear Systems Using Larval Stream Salamanders (Canadian Journal of Zoology [2009]: 292298) investigated whether water temperature...
-
The position of a particle undergoing simple harmonic motion is given by \(x(t)=20 \cos (8 \pi t)\), where \(x\) is in millimeters and \(t\) is in seconds. For this motion, what are the (a)...
-
Fill in the blanks to make the following statements correct. a. It is difficult to compare two or more data series when absolute numbers and different units are used. For that reason we construct...
-
Fill in the blanks to make the following statements correct. a. On a graph with Y on the vertical axis and X on the horizontal axis, the slope of a straight line is calculated as ___________. b. In...
Study smarter with the SolutionInn App