Computers and Technology

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();
}
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 04:31, caseypearson377
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
image
Computers and Technology, 23.06.2019 06:40, euniceyi56
How many nibbles can be stored in a 16-bit word?
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, jason9394
Facial expressions and gestures are examples of messages.
Answers: 3
image
Computers and Technology, 23.06.2019 15:00, puppylove899
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a. an advanced knowledge of physics and math b. an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
Do you know the correct answer?
Suppose that you are trying to write a program that produces the following output using loops. The p...

Questions in other subjects:

Konu
History, 11.02.2020 22:00