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!
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).
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!
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
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)...
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)
4) Write a java program where you will use while loop, where if condition is equal...
4) Write a java program where you will use while loop, where if condition is equal to 2 (or any other choice of your number) then it will break the while condition. Steps: 1) Declare variable int (any name) which is equal to zero 2) Declare while condition which variable int is less then equal to 10 3) Declare print out where the value of variable is the same name that you declared in step 1 4) Declare condition if...
Given the data set A = {5, 4, 6, 14, 2, 2, 11, 4, 5, 8,...
Given the data set A = {5, 4, 6, 14, 2, 2, 11, 4, 5, 8, 3, 1, 12, 15, 13}, which is the data of a sample taken from a larger population. Please Solve NOT Using Excel Calculate the mean deviation Show all work! (5 pts) Mean= 7 MD= (|5-7|+ |4-7|+ |6-7|+|14-7|+|2-7|+|2-7|+|11-7|+| 4-7|+ |5-7|+| 8-7|+| 3-7|+|1-7|+|12-7|+ |15-7|+| 137|)/7              Mean deviation = 4.13 Calculate the variance Show all work! (5 pts) Calculate the standard deviation Show all work! (5...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT