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, 22.06.2019 06:00
Write a function that draws a pool ball. this function should take as parameters, the color, the number that should go on the pool ball, and the location of the center of the pool ball. the radius of the pool balls should be pool_ball_radius, and the font of the number should be pool_ball_font. the text of the pool ball font should be white. drawpoolball(color.orange, 5, 100, 100); drawpoolball(color.green, 6, 50, 200); drawpoolball(color.red, 3, 150, 350); drawpoolball(color.blue, 2, 250, 140); to center the numbers on the pool ball, you should use the getwidth() and getheight() methods. you are allowed to call these methods on your text object, such as txt.
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Knowing that the central portion of link bd has a uniform cross sectional area of 800 mm2 , determine the magnitude of the load p for which the normal stress in link bd is 50 mpa. (hint: link bd is a two-force member.) ans: p = 62.7 kn
Answers: 2
question
Computers and Technology, 23.06.2019 09:00
Which best compares appointments and events in outlook 2010appointments have a subject man, and events do notappointments have a specific date or range of dates, and events do notappointments have a start and end time of day, and events do notappointments have a location option, and events do not
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
How do you share someone else’s tweet with your own twitter followers?
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
English, 10.01.2021 23:10
question
Mathematics, 10.01.2021 23:10
question
History, 10.01.2021 23:10
question
Mathematics, 10.01.2021 23:10
question
Social Studies, 10.01.2021 23:10
question
History, 10.01.2021 23:10
question
Mathematics, 10.01.2021 23:10
Questions on the website: 13722367