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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Which one of the following would administrators use to connect to a remote server securely for administration? a. telnetb. secure file transfer protocol (sftp)c. secure copy (scp)d. secure shell (ssh)
Answers: 1
question
Computers and Technology, 22.06.2019 12:40
The most complicated four letter word
Answers: 1
question
Computers and Technology, 24.06.2019 14:30
Two students are discussing electricity that has a frequency of 60 hz. student a says that this type of electricity is referred to as ac. student b says that in this type of electricity, the electrons flow in only one direction. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
Jacking is a crime that takes place when a hacker misdirects url to a different site. the link itself looks safe, but the user is directed to an unsafe page
Answers: 1
You know the right answer?
Suppose that you are trying to write a program that produces the following output using loops. The p...
Questions
question
Mathematics, 24.05.2021 19:30
question
Mathematics, 24.05.2021 19:30
question
Social Studies, 24.05.2021 19:30
question
History, 24.05.2021 19:30
question
Mathematics, 24.05.2021 19:30
question
Mathematics, 24.05.2021 19:30
Questions on the website: 13722367