help what am i doing wrong While loop Description: In this activity you will learn how to use a while loop. You will pri
Posted: Sun May 15, 2022 10:15 am
help what am i doing wrong
While loop
Description:
In this activity you will learn how to use a while loop. You
will print all the numbers from x to 6 (x being a mystery number).
You can assume x is always a larger number than 6. Please follow
the steps below:
Steps:
Test:
Use the test provided.
Sample output:
If x was 10.
10
9
8
7
6
code:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//--------------------------------------------------------
// Ignore. This is just used to get a mystery number
for x.
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number in the console
above 6.");
int x = sc.nextInt();
sc.close();
//--------------------------------------------------------
// Use a while loop to print the values of x to 6
decreasing in size by 1 each time.
while(-1);{
// Your code here:
System.out.println("x");
if (x<=10)
break;
While loop
Description:
In this activity you will learn how to use a while loop. You
will print all the numbers from x to 6 (x being a mystery number).
You can assume x is always a larger number than 6. Please follow
the steps below:
Steps:
Test:
Use the test provided.
Sample output:
If x was 10.
10
9
8
7
6
code:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//--------------------------------------------------------
// Ignore. This is just used to get a mystery number
for x.
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number in the console
above 6.");
int x = sc.nextInt();
sc.close();
//--------------------------------------------------------
// Use a while loop to print the values of x to 6
decreasing in size by 1 each time.
while(-1);{
// Your code here:
System.out.println("x");
if (x<=10)
break;