3. Hand write a method that uses a loop to compute the average of all integers...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3. Hand write a method that uses a loop to compute the average of all integers from 1 to n. You do not need to submit a java file, just directly write the code in this file. First, please do a time analysis, counting each basic operation (such as assignment and ++) as one operation (you need to show the details). Next, write the Big-O notation for the time complexity based on your time analysis. (5 points) Please keep in mind that just using integer division to calculate the average will return a truncated double. public double averageNumber(int n) { //your code goes here } 3. Hand write a method that uses a loop to compute the average of all integers from 1 to n. You do not need to submit a java file, just directly write the code in this file. First, please do a time analysis, counting each basic operation (such as assignment and ++) as one operation (you need to show the details). Next, write the Big-O notation for the time complexity based on your time analysis. (5 points) Please keep in mind that just using integer division to calculate the average will return a truncated double. public double averageNumber(int n) { //your code goes here }
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Miller Companys contribution format income statement for the most recent month is shown below: Total Per Unit Sales (41,000 units) $ 287,000 $ 7.00 Variable expenses 164,000 4.00 Contribution margin...
-
Stephen King, D.D.S., opened a dental practice on January 1, 2019. During the first month of operations, the following transactions occurred. 1. Performed services for patients who had dental plan...
-
The financial statements for BSW National Bank (BSWNB) are shown below: a. What is the dollar value of earning assets held by BSWNB? b. What is the dollar value of interest-bearing liabilities held...
-
The following information was reported in the December 31, 2007, financial statements of Southwest Airlines, Inc. (listed alphabetically, amounts in millions). Accounts Payable $1,731 Accounts...
-
The U.S. Energy Department states that 60% of all U.S. households have ceiling fans. In addition, 29% of all U.S. households have an outdoor grill. Suppose 13% of all U.S. households have both a...
-
Biogen Corporation will pay a quarterly dividend per share of $.0.65 at the end of each of the next 8 quarters. Thereafter, the dividend will grow at a quarterly rate of 1.4 percent, forever. The...
-
Their 1.5 inch, 90-degree copper elbow (see below) is a very popular item in the plumbing line that comes packaged in 10 elbows per box. The box costs about $65 to Western, and Western sells it at...
-
Consider the utility function U(X,Y) = 2X+2XY+2Y. (a) Does the marginal utility of X diminish, remain constant, or increase as the conomer buys more X, holding Y constant? Use derivative(s) to...
-
Some policy makers argue that it would be desirable to reward generators of hazardous wastes for appropriately disposing of their wastes. Describe a possible reward scheme. Why is it a good idea?...
-
Your boss, who never took an engineering economy course, is buying a new house and needs your help in answering some questions. The loan amount will be in the jumbo loan category of $600,000 at (1) 7...
-
Find all possible values for each expression. \((-1)^{1 / 4}\)
-
Using real-world examples, evaluate the effectiveness of minimum wages in achieving a more equitable distribution of income.
-
An interest rate is given as 10 percent per year nominal. Determine the effective annual rate if a. compounding is annual. b. compounding is daily. c. compounding is continuous.
-
The Big Group has established a new subsidiary, Rotto Ltd, in Bogoland where the unit of currency is the Bogo. The new company was set up in 31 December 20X3 when its balance sheet was as follows:...
-
Assessing simultaneous changes in CVP relationships Braun Corporation sells hammocks; variable costs are $75 each, and the hammocks are sold for $125 each. Braun incurs $240,000 of fixed operating...
-
In 2012, Gale and Cathy Alexander hosted an exchange student, Axel Muller, for 9 months. Axel was part of International Student Exchange Programs (a qualified organization). Axel attended tenth grade...
-
Janie graduates from high school in 2012 and enrolls in college in the fall. Her parents pay $4,000 for her tuition and fees. a. Assuming Janie's parents have AGI of $170,000, what is the American...
-
Linda and Richard are married and file a joint return for 2012. During the year, Linda, who works as an accountant for a national airline, used $2,100 worth of free passes for travel on the airline;...
-
A diver leaps from a high platform, speeds up as she falls, and then slows to a stop in the water. How do you define the system so that the energy changes are all transformations internal to an...
-
When your hands are cold, you can rub them together to warm them. Explain the energy transformations that make this possible.
-
Figure Q10.24 shows a potential-energy diagram for a particle. The particle is at rest at point A and is then given a slight nudge to the right. Describe the subsequent motion. FIGURE Q10.24 Energy...
Study smarter with the SolutionInn App