Suppose that you are trying to write a program that produces the following output: 1 3 5
Question:
Suppose that you are trying to write a program that produces the following output:
1 3 5 7 9 11 13 15 17 19 21
1 3 5 7 9 11
The following program is an attempt at a solution, but it contains four major errors. Identify them all.
Transcribed Image Text:
1. public class BadNews { public static final int MAX_ODD = 21; public static void writeOdds () { 4. // print each odd number for (int count = 1; count <= (MAX_ODD 2); count++) { System.out.print (count + " "); count = count + 2; 9. 10 / print the last odd number 11 12 System.out.print (count + 2); 13 14 15 public static void main (String[] args) { 16 // write all odds up to 21 17 writeOdds () ; 18 19 // now, write all odds up to 11 20 MAX ODD = 11; 21 writeOdds (); 22 23 2. 3.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 72% (11 reviews)
Mistakes in BadNews program 1 The loop prints every third number not every odd n...View the full answer
Answered By
Robert Mbae
I have been a professional custom essay writer for the last three years. Over that period of time, I have come to learn the value of focusing on the needs of the clients above everything else. With this knowledge, I have worked hard to become an acclaimed writer that can be trusted by the customers to handle the most important custom essays. I have the necessary educational background to handle projects up to the Ph.D. level. Among the types of projects that I've done, I can handle everything within Dissertations, Project Proposals, Research Papers, Term Papers, Essays, Annotated Bibliographies, and Literature Reviews, among others.
Concerning academic integrity, I assure you that you will receive my full and undivided attention through to the completion of every essay writing task. Additionally, I am able and willing to produce 100% custom writings with a guarantee of 0% plagiarism. With my substantial experience, I am conversant with all citation styles ranging from APA, MLA, Harvard, Chicago-Turabian, and their corresponding formatting. With all this in mind, I take it as my obligation to read and understand your instructions, which reflect on the quality of work that I deliver. In my paper writing services, I give value to every single essay order. Besides, whenever I agree to do your order, it means that I have read and reread your instructions and ensured that I have understood and interpreted them accordingly.
Communication is an essential part of a healthy working relationship. Therefore, I ensure that I provide the client with drafts way long before the deadline so that the customer can review the paper and comment. Upon completion of the paper writing service, the client has the time and right to review it and request any adjustments before releasing the payment.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted:
Students also viewed these Computer science questions
-
Suppose that you are trying to compare two populations on some variable (GMAT scores of men versus women, for example). Specifically, you are testing the null hypothesis that the means of the two...
-
Write a program that produces the following output using nested for loops. Use a class constant to make it possible to change the number of stairs in the figure. ******* /* ****** ****** / * ****** /*
-
Write a program that produces the following output using nested for loops: ////**... **. ..... ... .... ... ..
-
Carter Co. has a value of $80 million. Buleigh is otherwise identical to Carter Co., but has $32 million in debt. Suppose that both firms are growing at a rate of 5%, the corporate tax rate is 38%,...
-
Consider a simple ideal Brayton cycle operating between the temperature limits of 300 and 1500 K. Using constant specific heats at room temperature, determine the pressure ratio for which the...
-
Use fractional equivalents to compute each of the following (round to the highest whole number). Do not convert percentages to decimals. 25% of $440
-
What is a Wohler curve?
-
The vapor pressure of toluene is given in Exercise 4.8, and that of n-heptane is given in the accompanying table. (a) Plot an x-y equilibrium diagram for this system at 1 atm by using Raoult's and...
-
Losing to a Weaker Foe What began as a heavily conventional military campaign to unseat the regime of Saddam Hussein had become a bitter, unconventional struggle against frustrated Sunnis who...
-
3/184 The 15 200-kg lunar lander is descending onto the moon's surface with a velocity of 2 m/s when its retro-engine is fired. If the engine produces a thrust T for 4 s which varies with time as...
-
What is the output of the following unknown method? public class Strange { public static final int MAX 5; 3 4 public static void unknown () { int number = 0; 7 for (int count MAX; count >= 1;...
-
What is the output of the following sequence of loops? Notice that the code is the same as that in the previous exercise, except that the placement of the braces has changed. for (int i = 1; i
-
Same facts as above except that the client is secretly discharging a lethal chemical into the water system. You have reason to believe that people are likely to die as a result of the illegal...
-
Power-circuit breakers are intended for service in the ac circuit above ____________ V.
-
If you were going to spend time in Italy, France, and Germany, you would be paying for things with __________. a) lira, francs, and marks b) dollars c) euros d) gold
-
A circuit breaker is designed to extinguish the arc by ____________.
-
In the positive-sequence network of a synchronous motor, a source voltage is represented, whereas in that of an induction motor, the source voltage (a) does or (b) does not come into picture.
-
In circuit breakers, besides air or vacuum, what gaseous medium, in which the arc is elongated, is used?
-
An object has an angular size of 0.0150 rad when placed at the near point (21.0 cm) of an eye. When the eye views this object using a magnifying glass, the largest possible angular size of the image...
-
Evaluate the function at the given value(s) of the independent variable. Simplify the results. (x) = cos 2x (a) (0) (b) (- /4) (c) (/3) (d) ()
-
Assume that registers $s0 and $s1 hold the values 0x80000000 and 0xD0000000, respectively. 1. What is the value of $t0 for the following assembly code? add $t0, $s0, $s1 2. Is the result in $t0 the...
-
Assume that $s0 holds the value 128 ten . 1. For the instruction add $t0, $s0, $s1, what is the range(s) of values for $s1 that would result in overflow? 2. For the instruction sub $t0, $s0, $s1,...
-
Provide the type and assembly language instruction for the following binary value: 0000 0010 0001 0000 1000 0000 0010 0000 two .
-
Blue Company changed depreciation methods in 2025 from double-declining balance to straight-line. Depreciation prior to 2025 under double-declining-balance was 592,400, whereas straight-line...
-
Figure out, salaries, net income, add net income with retained earnings and totally stockholder equity , ?accounts payable and total liabilities and stockholders equity RILEY, INCORPORATED Statement...
-
Determine the material inventory balance at the end of may? Received Issued Receiving Received Materials Report Number Received Quantity Unit Price Requisition Number Issued Quantity Issued Balance...
Study smarter with the SolutionInn App