Question

In Java programming language 11.Create the code for a for loop to print the numbers 1  through...

In Java programming language

11.Create the code for a for loop to print the numbers 1  through 5 inclusive vertically so the output is

1

2

3

4

5

11b What is the output of the following               OUTPUT

int i=3;

while(int i >0)

{

System.out.println(i);

i--;

}

11c What is the output of the following               OUTPUT

for(int i=3;i<10;i++)

System.out.println(3*i);

11d Create the line of code to print the numbers 10 through 1 decreasing by 1 each time

11e Create the line of code to print Your first  name 5 times vertically

Homework Answers

Answer #1

Answer1:

public class Main
{
public static void main(String[] args)
{
for(int i = 1; i <= 5; i++)
{
System.out.println(i);
}
}
}

Explanation: There is simple for loop used from 1 to 5 and incremented by1.

Answer2: 3

2

1

Explanation: i starts from 3 and decremented by 1 every time.

Answer3:

9

12

15

18

21

24

27

Explanation: loop starts from 3 and less than 10, each loop will multiply by 3.

Answer4:

public class Main
{
public static void main(String[] args)
{
for(int i = 10; i >= 1; i--)
{
System.out.println(i);
}
}
}
Explanation: i starts from 10 to greater than equal to 1 and decremented by 1 every time

Answer5 :

public class Main
{
public static void main(String[] args)
{
for(int i = 1; i <= 5; i++)
{
System.out.println("First Name");
}
}
}

Explanation: Loop starts from 1 to less than equal to 5 and incremented by. Each iteration will print First name.

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
Create a JAVA program to display the numbers 1-10. Although you could program a solution that...
Create a JAVA program to display the numbers 1-10. Although you could program a solution that has ten lines of code like the following, think about why this would be a bad idea when developing a programming solution: Print 1 Print 2 Print 3 Print 4 (continued to Print 10) Note: Examples for Java programs (Loop and no loop) programs are in the "Important Documents" folder / Module 6.
Write a Java code snippet with a nested for loop to print five rows of six...
Write a Java code snippet with a nested for loop to print five rows of six random integers between 5 and 10 inclusive.
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)...
java: can anyone explain. why does my code print out ##### and ***** instead of just...
java: can anyone explain. why does my code print out ##### and ***** instead of just #####? int a=1, b=2, c=3;    if(a<b) System.out.println("####"); else System.out.println("&&&&"); System.out.println("****");
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
(java) a. The following code has compilation AND logic errors. Rewrite the code (using the while...
(java) a. The following code has compilation AND logic errors. Rewrite the code (using the while loop) so it will compile correctly and print all the even numbers from 0 to 10 on one line separated by a space: int j = 0; while j > 10 ; j + 2; System.println(j, “ “); b.You want to print the values of integers a and b to an external file “test123.txt”, assigned to the PrintWriter variable output. Correct the following statements:...
JAVA - take each for loop and rewrite as a while statement a) int result =...
JAVA - take each for loop and rewrite as a while statement a) int result = 0; for (int i = 1; i <= 10; i++) { result = result + i;} System.out.println(result); b) int result = 1; for (int i = 1; i <= 10; i++) {result = i - result;} System.out.println(result); c) int result = 1; for (int i = 5; i > 0; i--) {result = result * i;} System.out.println(result); d) int result = 1; for (int...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3 Please use my template import java.util.Scanner; public class...
Using a for loop and range command, print the sequence of numbers from 1 to 20...
Using a for loop and range command, print the sequence of numbers from 1 to 20 (skipping two numbers for each element); that is, your code should print out the numbers 1,4, 7, 10, … (max should not exceed 20). Use x as the variable name
JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO...
JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO YOU I NEED YOUR HELP PLEASE HELP ME. I WILL GIVE UPVOTE AND GOOD COMMENT THANK YOU SO MUCH !!! QUESTION 1 What is the output after the code executes? Assume there are no syntax errors and the code will compile. int x = 10; do { System.out.println ( x ); x -= 3; } while (x > 0); A. 10 7 4 1...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT