Java Question I can\'t figure this out I have tried so many diffrent ways. Instr
ID: 3774519 • Letter: J
Question
Java Question
I can't figure this out I have tried so many diffrent ways.
Instructions
Write a while loop that prints 1 to userNum, using the variable i. Follow each number (even the last one) by a space. Assume userNum is positive. Ex: userNum = 4 prints:
all of the code in bold can not be changed only the " /* Your solution goes here */ " can be changed this is in a learning program not an IDE
import java.util.Scanner;
public class CountDown {
public static void main (String [] args) {
int userNum = 0;
int i = 0;
userNum = 4; // Assume positive
/* Your solution goes here */
System.out.println("");
return;
}
}
Thank You
Explanation / Answer
import java.util.Scanner;
public class CountDown {
public static void main (String [] args) {
int userNum = 0;
int i = 0;
userNum = 4; // Assume positive
cout<<("userNum = %d ",userNum);
while(i != userNum) {
i++;
cout<<("%d",i);
}
cout << endl;
System.out.println("");
return;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.