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, 22.06.2019 11:30
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Guys do you know sh27 cause he hacked me : ( pidgegunderson my old user
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
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
Chemistry, 25.11.2020 17:20
question
Computers and Technology, 25.11.2020 17:20
question
Mathematics, 25.11.2020 17:20
Questions on the website: 13722360