subject

(Display four patterns using loops) Ask the user to enter an integer to
set a limit for nested loops and generate the following four patterns:

Enter an integer to be a limit of the pattern:6
Pattern A:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6

Pattern B:
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Pattern C:
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1

Pattern D:
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1 Complete answer in java please. this is what i have including error message:

LoopPattern. java:1: error: class, interface, or enum expected
looppattern;
^
1 error

1 looppattern;
2 public class Looppattern{
3 public static void main(String []args){
4 scanner sc = new scanner(System. in);
5 System. out. println("Enter how man levels you need: ");
6 int levels = sc. nextInt();
7 System. out. println("\nPattern A\n");
8 for(int p=1;p<=levels;p++){
9 for(int k=1;k<=p;k++){ //increasing each level printing
10 System. out. print(k);
11 }
12 System. out. println();
13 }
14 System. out. println("\nPattern B\n");
15 int r=levels;
16 for(int p=1;p<=levels;p++){
17 for(int k=1;k<=r;k++){
18 System. out. print(k);
19 }
20 r--; //decreasing levels
21 System. out. println();
22 }
23 System. out. println("\nPattern C\n");
24 for(int p=1;p<=levels;p++){ //here incresing
25 for(int k=p;k>0;k--){ //and here decreasing pattern to achieve our required pattern
26 System. out. print(k);
27 }
28 System. out. println();
29 }
30 System. out. println("\nPattern D\n");
31 r=levels;
32 for(int p=1;p<=levels;p++){
33 for(int k=1;k<=r;k++){
34 System. out. print(k);
35 }
36 r--; //decreasing levels
37 System. out. println();
38 }
39 }
40 }

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 08:00
Match the items with their respective descriptions.
Answers: 1
question
Computers and Technology, 24.06.2019 00:50
3. what is the output of the following statements? temporary object1; temporary object2("rectangle", 8.5, 5); temporary object3("circle", 6, 0); temporary object4("cylinder", 6, 3.5); cout < < fixed < < showpoint < < setprecision(2); object1.print(); object2.print(); object3.print(); object4.print(); object1.set("sphere", 4.5, 0); object1.print();
Answers: 1
question
Computers and Technology, 24.06.2019 13:50
What does code do? a creates a text box that says "solid black" b creates a black border of any width c creates a black border 1 pixel wide
Answers: 1
question
Computers and Technology, 24.06.2019 14:30
Alison is having a hard time at work because hee inbox is flooded with emails every day. some of these emails are unsolicited. some of other she don’t need. which action should she take to better manager her emails?
Answers: 1
You know the right answer?
(Display four patterns using loops) Ask the user to enter an integer to
set a limit for nested...
Questions
question
Mathematics, 24.03.2021 17:40
question
Mathematics, 24.03.2021 17:40
question
Business, 24.03.2021 17:40
question
Mathematics, 24.03.2021 17:40
question
Computers and Technology, 24.03.2021 17:40
question
History, 24.03.2021 17:40
Questions on the website: 13722359