Declare a Boolean variable named allAllowed. Then, read integer inCount from input representing the number of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Declare a Boolean variable named allAllowed. Then, read integer inCount from input representing the number of integers to be ead next. Use a loop to read the remaining integers from input. If none of the inCount integers are in the range -1000 to -100 nclusive, assign allAllowed with true. Otherwise, assign allAllowed with false. Code at the end of main() outputs "Only allowed value(s)" if allAllowed is true or "Unallowed value(s)" if allAllowed is false. Ex: If the input is: 550 -90 hen the output is: nallowed value(s) 2345 1000 co 3 public class IntegerReview { 6 7 8 9 10 11 12 13 14 15 9 16 17 18} public static void main(String[] args) { Scanner scnr = new Scanner (System.in); int inCount; /* Additional variable declarations go here */ /* Your code goes here / if (allAllowed) { System.out.println("Only allowed value(s)"); } } else { } System.out.println("Unallowed value(s)"); Declare a Boolean variable named allAllowed. Then, read integer inCount from input representing the number of integers to be ead next. Use a loop to read the remaining integers from input. If none of the inCount integers are in the range -1000 to -100 nclusive, assign allAllowed with true. Otherwise, assign allAllowed with false. Code at the end of main() outputs "Only allowed value(s)" if allAllowed is true or "Unallowed value(s)" if allAllowed is false. Ex: If the input is: 550 -90 hen the output is: nallowed value(s) 2345 1000 co 3 public class IntegerReview { 6 7 8 9 10 11 12 13 14 15 9 16 17 18} public static void main(String[] args) { Scanner scnr = new Scanner (System.in); int inCount; /* Additional variable declarations go here */ /* Your code goes here / if (allAllowed) { System.out.println("Only allowed value(s)"); } } else { } System.out.println("Unallowed value(s)");
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class IntegerReview publi... View the full answer
Related Book For
Java How To Program Early Objects
ISBN: 9780134743356
11th Edition
Authors: Paul Deitel, Harvey Deitel
Posted Date:
Students also viewed these programming questions
-
Explain the FOUR ways you can map EERD to Relational Model?
-
Executives at Southwestern Construction have noticed that the company's construction team in the Phoenix office is more efficient with its resources than the other teams in the Las Vegas, Salt Lake,...
-
The fiscal year-end unadjusted trial balance for Hall Company is found on the trial balance tab. Rent expense and salaries expense are equally divided between selling activities and general and...
-
What is wrong with the following code fragment? int[] a; for (int i = 0; i < 10; i++) a[i] = i * i;
-
Two forces F 1 and F 2 in space have the same magnitude F. Prove that the moment of F 1 about the line of action of F 2 is equal to the moment of F 2 about the line of action of F 1 .
-
The pump shown draws water (20C) through a 20 cm suction pipe and discharges it through a 11 cm pipe in which the velocity is 3 m/s. The 10 cm pipe discharges horizontally into air at point C. To...
-
Select two of the approach strategies and develop each one into a one-page dialogue between you and a customer.
-
What makes for a good investment? Use the approximate yield formula or a financial calculator to rank the following investments according to their expected returns. a. Buy a stock for $30 a share,...
-
A 2.2-kg fire rocket travels east 50 meters in 4.2 seconds and then it explodes and breaks apart into 3 pieces. The first piece is 1.2-kg and travels west at 7 m/s. The second piece is 0.7-kg and...
-
Cherry Cotta makes custom ordered clay pots for residential gardens. Below is cost information regarding its latest job. a. Materials were purchased on account. $18,996 purchased b. A materials...
-
1. Discuss your scores. How you will use the information to improve in any areas in which you scored lower? Describe how you can build upon your areas of strength? 2. Discuss the areas in which you...
-
At the end of five years, you will receive $15,000 and deposit this in the bank toward your goal of $59,000 at the end of year 12. In addition to the lump-sum deposit, how much must you deposit in...
-
You bought shares in Wasatch Small Cap Investor Fund, spending $10,000. The fund has an annual net expense ratio of 1.27%. If the fund earns an average return of 8% annually before deducting the net...
-
1. The expected return on the market portfolio is 9%. The risk free rate is 5%. The variance of the market portfolio returns is 0.08 and the covariance of the market and GE returns is 0.06. a....
-
Bill and Ted are both covered by long-term disability policies that are fundamentally identical except for their premiums. Bill has no health risks, works in a low-risk job, and has a policy that...
-
Long-term debt outstanding = $300,000 Yield to maturity (r D ) = 8% Number of shares of common stocks = 10,000 Price per share = $50 Book value per share = $25 Beta of common stock = 1.5 Expected...
-
30. Your opinion is that CSCO has an expected rate of return of 0.15. It has a beta of 1.3. The risk-free rate is 0.04 and the market expected rate of return is 0.115. According to the Capital Asset...
-
1. Firms may hold financial assets to earn returns. How the firm would classify financial assets? What treatment will such financial assets get in the financial statements in accordance with US GAAP...
-
What does the following code do? public int mystery(int a, int b) { if (b == 1) { return a; } else { return a + mystery(a, b - 1); } }
-
A is needed to terminate recursion. a. Recursion step b. Break statement c. Void return type d. Base case
-
Iteration and recursion each involve a(n) . a. Iteration statement b. Termination test c. Counter variable d. None of the above
-
Figure P17.65 shows the light intensity on a screen behind a single slit. The wavelength of the light is \(500 \mathrm{~nm}\) and the screen is \(1.0 \mathrm{~m}\) behind the slit. What is the width...
-
If sunlight shines straight onto a peacock feather, the feather appears bright blue when viewed from \(15^{\circ}\) on either side of the incident beam of sunlight. The blue color is due to...
-
The shiny surface of a CD is imprinted with millions of tiny pits, arranged in a pattern of thousands of essentially concentric circles that act like a reflection grating when light shines on them....
Study smarter with the SolutionInn App