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. 1 3 5 7 9 11 13 15 17 19 21
1 3 5 7 9 11

public class BadNews {
public static final int MAX_ODD = 21;

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

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

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 23:30, keviongardner
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
image
Computers and Technology, 23.06.2019 08:30, sofigaviria05
All of these are true about using adhesive except: a. dissimilar materials can be joined. b. mixing tips are product and material specific. c. a specific application gun may be required. d. two-part adhesives are dispensed using two mixing tips
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, erjalinalii
Janice recently received her college degree and is looking for a job. she is worried that since she just finished school, she will be required to repay her perkins and direct subsidized loans immediately. janice pulls out the paperwork she signed and reviews it again for repayment information. after reading all of the information, janice discovers that
Answers: 2
image
Computers and Technology, 23.06.2019 22:30, cuki96
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
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, 30.05.2020 06:59