Find and fix the errors in the code snippets in this file. You can copy the code
ID: 3656187 • Letter: F
Question
Find and fix the errors in the code snippets in this file. You can copy the code into Bluej to help you find the errors. a) Assume age has been defined. This code should print if the age is greater than or equal to 65 or less than 65 if (age >= 65); System.out.println("Age greater than or equal to 65"); else System.out.println("Age is less than 65"); b) This code should find the sum of the numbers 1 through 10 int x = 1; int total; while (x <= 10) { total = total + x; x++; } c) This code should print the numbers 1 to 10, one to a line int x = 1; while (x <=10) System.out.println(x); x++; d) This code should print the numbers 100 to 1 for (int i = 100; i >= 1; i++) System.out.println(i); e) This code should declare and define an int array with initial values int array = {1 2 3 4 5};Explanation / Answer
public class myClass { public static void main(String[] args) { int age = 75; System.out.println(" ---- Age is set to 75 ---- " + " " ); if (age >= 65) { System.out.println("Age greater than or equal to 65"); } else { System.out.println("Age is less than 65"); } System.out.println(""); //b) This code should find the sum of the numbers 1 through 10 int x = 1; int total; while (xRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.