Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. (3 points) Consider the following method: public static void countDown(int n) { for (int count = n; count >= 1; count--) { System.out.println(count); }
2. (3 points) Consider the following method: public static void countDown(int n) { for (int count = n; count >= 1; count--) { System.out.println(count); } } When the input n is a positive integer, this method "counts down" from n, printing the integers from n down to 1. For example, countDown(5) would print 5 4 3 2 1 If n is less than or equal to 0, the method does not print anything. We have included the original method in ps1_partI. Rewrite it so that it uses a while loop instead of a for loop
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started