subject

Suppose that you are trying to write a program that produces the following output using loops. The program below is an attempt at a solution, but it contains at least four major errors. Identify and fix them all. Your solution must have a class constant. A constant must be declared as 'public static final' outside of any methods in your class. 1 3 5 7 9 11 13 15 17 19 21 1 3 5 7 9 11

public class BadNews {
public static int MAX_ODD = 21;

public static void writeOdds() {
// print each odd number
int count=0;
for ( count = 1; count <= (MAX_ODD - 2); count++) {
System. out. print(count + " ");
count = count + 1;
}

// print the last odd number
System. out. print(count);
System. out. println();
}

public static void main(String[] args) {
// write all odds up to 21
writeOdds();

// now, write all odds up to 11
MAX_ODD = 11;
writeOdds();
}
}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, yeeet26
If an improvement creates no significant change in a product’s performance, then it is a(n) ? a0 design improvement. (there are no answer choices)
Answers: 1
image
Computers and Technology, 23.06.2019 10:00, lamanihill
Now, open this passage to read about fafsa requirements. describe the information you will need to provide in order to complete a fafsa. list at least three of the required documents you must include.
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, sawyerfauver
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
image
Computers and Technology, 24.06.2019 00:30, sethhdoty
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
You know the right answer?
Suppose that you are trying to write a program that produces the following output using loops. The p...

Questions in other subjects:

Konu
Mathematics, 03.05.2020 13:01
Konu
Mathematics, 03.05.2020 13:01
Konu
Mathematics, 03.05.2020 13:01
Konu
Mathematics, 03.05.2020 13:01