1. (4 points; 2 points each) Suppose we have the method defined below: public static int...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. (4 points; 2 points each) Suppose we have the method defined below: public static int percentOutOfRange Exclusive (Scanner keyboard, String prompt, int low, int high, int count) { int outOfRange int reps = 0; = 0; // Counter controlled loop while (reps < count) { // Read input System.out.println(prompt); int entry = keyboard.nextInt(); keyboard.nextLine(); // Increment outOfRange if the entry is not between low and high // exclusive if (entry low || entry > high) { outOfRange = outOfRange + 1; } reps = reps + 1; } } return (int) Math.round(outOfRange * 100.0/ count); a) Write a complete main program that calls the method above to print to the console the percent of 50 values entered at the keyboard that are not between 1 and 10 (exclusive). Because the Scanner is a parameter, it will need to be declared and constructed in the main program. Write your own prompt. b) Write a complete main program that calls the method above to print to the console the percent of 10000 values entered at the keyboard that are not between -1000 and 1000 (exclusive). Because the Scanner is a parameter, it will need to be declared and constructed in the main program. Write your own prompt. 2. (5 points; 1 point each line) In the percentOutOfRange Exclusive method from problem 1, show all identifiers that fall into each category. Some lines may be blank. Parameter(s) Arguments(s) Local variables Return type Method name 1. (4 points; 2 points each) Suppose we have the method defined below: public static int percentOutOfRange Exclusive (Scanner keyboard, String prompt, int low, int high, int count) { int outOfRange int reps = 0; = 0; // Counter controlled loop while (reps < count) { // Read input System.out.println(prompt); int entry = keyboard.nextInt(); keyboard.nextLine(); // Increment outOfRange if the entry is not between low and high // exclusive if (entry low || entry > high) { outOfRange = outOfRange + 1; } reps = reps + 1; } } return (int) Math.round(outOfRange * 100.0/ count); a) Write a complete main program that calls the method above to print to the console the percent of 50 values entered at the keyboard that are not between 1 and 10 (exclusive). Because the Scanner is a parameter, it will need to be declared and constructed in the main program. Write your own prompt. b) Write a complete main program that calls the method above to print to the console the percent of 10000 values entered at the keyboard that are not between -1000 and 1000 (exclusive). Because the Scanner is a parameter, it will need to be declared and constructed in the main program. Write your own prompt. 2. (5 points; 1 point each line) In the percentOutOfRange Exclusive method from problem 1, show all identifiers that fall into each category. Some lines may be blank. Parameter(s) Arguments(s) Local variables Return type Method name
Expert Answer:
Related Book For
Quantitative Investment Analysis
ISBN: 978-1119104223
3rd edition
Authors: Richard A. DeFusco, Dennis W. McLeavey, Jerald E. Pinto, David E. Runkle
Posted Date:
Students also viewed these programming questions
-
answer the question clearly Implement a videogame called JavaConk, a computerised version of the game of conkers. Two round conkers should be displayed on the screen. One conker is controlled by the...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
As manager of a local pizza parlor, you want to develop a balanced scorecard so you can more effectively monitor the restaurants performance. Required a. Propose at least two goals for each...
-
In a steam power plant operating on the ideal regenerative Rankine cycle with one open feed water heater, steam enters the turbine at 9 MPa, 480oC and is condensed in the condenser at a pressure of 7...
-
Pool Corporation is authorized to issue an unlimited number of common shares and 1 , 0 0 0 , 0 0 0 shares of preferred shares. During 2 0 2 3 , its first year of operation, the company had net income...
-
Consider a continuous-time environment, with \(e\) as a variable outside of the market. (a) Suppose the final payoff is \(V\left(x_{e}, T ight)=x_{e}(T)\). Find \(V\left(x_{e}, t ight)\). (b) Find a...
-
The cost of goods sold computations for Target Company and Caesar Company are shown below. Instructions(a) Compute inventory turnover and days in inventory for each company.(b) Which company moves...
-
How can systems theory inform the development of holistic frameworks for assessing the multifaceted dimensions of empowerment within complex adaptive systems ? Explain
-
2. National Defense (40 points). There are 11 countries in Europe who get utility from general consumption c, and from European national defense G. The utility of a generic country i is u(ci, G) =...
-
A firm is considering relaxing credit standards, which will result in annual sales increasing from $1.5 million to $1.75 million, the cost of annual sales increasing from $1,000,000 to $1,125,000,...
-
Jeremiah is working on a model bridge. He needs to create triangular components, and he plans to use toothpicks. He finds three toothpicks of lengths 4 in., 5 in., and 2 in. Will he be able to create...
-
Apple stock is currently selling at 200$. You purchase a 30 day call with a strike price of 200$ for 18$ and 30 day put for the same strike price for 20$. What are your total losses or gain at prices...
-
After Dans analysis for East Coast Yachts (see the Case study for Module 2), Larissa has decided to expand the companys operations. She has asked Dan to enlist an underwriter to help sell $50 million...
-
8. Sam bought a house that costs $500,000. Sam got a 96% LTV loan. The lender demanded that Sam buy private mortgage insurance to insure the portion of the loan over 75% LTV. Suppose 5 years later,...
-
Parker & Stone, Inc. is looking at setting up a new manufacturing plant in South Part to produce garden tools. The company bought some land six years ago for $5 million in anticipation of using...
-
Three successive resonance frequencies in an organ pipe are 1310, 1834, and 2358 Hz. (a) Is the pipe closed at one end or open at both ends? (b) What is the fundamental frequency? (c) What is the...
-
Name three or more branches of Earth science, and describe the focus of each.
-
How does seafloor spreading relate to continental drift?
-
Describe how tectonic plates move in terms of speed and direction.
Study smarter with the SolutionInn App