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

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.

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

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

Step by Step Solution

3.33 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Mistakes in BadNews program 1 The loop prints every third number not every odd n... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!