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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:50
Answer the following questions regarding your system by using the commands listed in this chapter. for each question, write the command you used to obtain the answer. a. what are the total number of inodes in the root filesystem? how many are currently utilized? how many are available for use? b. what filesystems are currently mounted on your system? c. what filesystems are available to be mounted on your system? d. what filesystems will be automatically mounted at boot time?
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 23.06.2019 12:30
What is the difference between the internet and the world wide web?
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
The basic work area of the computer is it screen that you when you first fire up your computer
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, 08.10.2020 05:01
question
Mathematics, 08.10.2020 05:01
Questions on the website: 13722362