Question

JAVA Write a while which will display this set of values 10, 4, -2, -8, -14.

JAVA

Write a while which will display this set of values 10, 4, -2, -8, -14.

Homework Answers

Answer #1

Hello learner,

Thanks for asking.

# Here is the exact code used to print the above statement in java

class Main
{
public static void main(String s[])
{
int n = 10;

while( n >= -14 )
{
System.out.print( n + " " );
n=n-6;
}
}
}

Use proper indentation for less error.

In this code at first initializtion is done and then one by one integer is printed which less than -14 with a gap of 6.

To print all the integers a same line print() is used instead of println().

please upvote and ask if you have any query.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Step 2 Exercise - Using while loop:    Write a Java program (using while loop) to display...
Step 2 Exercise - Using while loop:    Write a Java program (using while loop) to display 5 lines of smiley faces. The following would be the output of your program: Note: Sample program is in the "Important Documents", Module 6 folder) Hello:                          Bye!
In Java Write a JavaFX application that allows the user to pick a set of pizza...
In Java Write a JavaFX application that allows the user to pick a set of pizza toppings using a set of check boxes. Assuming each topping cost 50 cents, and a plain pizza costs $10, display the cost of the pizza.Us an Hbox thank you!
Write a C program that will show the following output: 20 14 8 2 -4 -10...
Write a C program that will show the following output: 20 14 8 2 -4 -10 … …. (n terms, where you can specify n).
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
A. Calculate the variance of the data set 8, 4, 14, 10, 7 B. Make a...
A. Calculate the variance of the data set 8, 4, 14, 10, 7 B. Make a box and whisker plot for the data 1 5 5 6 7 8 8 10 10 14
Write an EBNF rules that describes the following while statement of Java. Then, write the recursive-descent...
Write an EBNF rules that describes the following while statement of Java. Then, write the recursive-descent subprogram in Java for the EBNF rule. Please summit your source code and a screen shot of the parsing of the following examples. do { if ( number % 2 == 0 ) even ++; number=number+1; } while (number <= 10)
B.2. Write a Java program to display a dialog box that asks you to enter your...
B.2. Write a Java program to display a dialog box that asks you to enter your user name and the age as shown below: The program displays in a dialog box the sum of digits of your age. For example, if you age is 19, the sum will be 1+9 = 10 and the output will be as shown below: ( it just shows a message box that says the sum of the digits age of john is 10.
Given the data set A = {5, 4, 16, 14, 2, 2, 11, 4, 5, 8,...
Given the data set A = {5, 4, 16, 14, 2, 2, 11, 4, 5, 8, 3, 1, 12, 15, 13}, which is the data of a sample taken from a larger population Calculate the mean deviation (5 pts) Calculate the variance (5 pt Calculate the standard deviation (5 pts)
Write a java program to display a given range of integer numbers (0 to 9) in...
Write a java program to display a given range of integer numbers (0 to 9) in the following order: Example : given (5 to 9), the program displays 56789 67895 78956 89567 95678 The first line displays the min to max range. Each line that follows should display the next higher number except when it hits the maximum number. In that situation, the line wraps back to the minimum sequence. For this problem write a static method to do the...
write a java code. Write a program using loops to compute the sum of the 30...
write a java code. Write a program using loops to compute the sum of the 30 terms of the series below. 91/(3 + 2 + 2) + 92/(4 - 4 + 5) + 93/(5 + 6 - 8) + 94/(6 - 8 + 11) + 95/(7 + 10 + 14) + 96/(8 - 12 - 17) + . . . . Output: Term Ratio Sum 1 13 13 2 18.4 31.4 etc etc