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
In Java ReWrite the for loop program code example 3, above as a while loop. Code...
In Java ReWrite the for loop program code example 3, above as a while loop. Code Example 3 – Try it import java.util.Scanner; public static void main(String args[]) { int count = 0; int maxNumber = 0; int enteredNumber = -9999999; System.out.println("This program determines which entered number is the largest "); System.out.println("Enter count of numbers to check: "); Scanner scanIn = new Scanner(System.in); double count = scanIn.nextDouble(); scanIn.close(); // Print out message – input number – compare to see if...
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)...
1) Write a java programming nested while loop where you will declare two numbers one for...
1) Write a java programming nested while loop where you will declare two numbers one for outer loop and the other one for inner while loop, and display the result. (Try using scanner) Steps: 1) Declare the variable of outer loop int and assign value of your choice 2) Declare while condition which outer variable is less the number of your choice 3) Declare variable of inner loop int and assign the value of your choice 4) Declare while condition...
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: 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("****");
(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:...
USING JAVA LANGUAGE : Using Doubly Linked List, create a java code that does the following...
USING JAVA LANGUAGE : Using Doubly Linked List, create a java code that does the following Without using LinkedList from the JAVA LIBRARY. and please include methods for each function. Create a menu that contains the following operations : 1. Add new node to DLL. ( as a METHOD ) 2. Delete a node from DLL. ( as a METHOD ) 3. Show how many nodes in DLL. ( as a METHOD ) 4. Print all data in the DLL....
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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT