1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Natalija [7]
4 years ago
5

Write a Java program that prompts the user for an int n. You can assume that 1 ≤ n ≤ 9. Your program should use embedded for loo

ps that produce the following output: 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 . . . n . . . 5 4 3 2 1 Your prompt to the user should be: Please enter a number 1...9 : Please note that your class should be named PatternTwo.

Computers and Technology
1 answer:
zlopas [31]4 years ago
8 0

Answer:

Here is the JAVA program:

import java.util.Scanner;  // to take input from user

public class PatternTwo{   //class name

public static void main(String args[]){  //start of main function

Scanner scan = new Scanner(System.in);   // creates Scanner class object

System.out.print("Please enter a number: ");  //prompts user to enter an int n for the number of rows

int n = scan.nextInt();   //reads and scans the value of n from user

int i, j;   //declares two variables to iterate through i  rows and j columns

for (i=1; i<=n; i++){    //outer loop for rows  

for (j=2*(n-i); j>=1; j--){   //inner loop for space between numbers in pattern  

System.out.print(" ");  }   //displays an empty space in the pattern

for (j = i; j >= 1; j--)  { //inner loop for columns  

System.out.print(j+" "); }   //prints the value of j (prints numbers in reverse)

System.out.println();   }   }   }  //prints a new line after printing each row

Explanation:

The program is explained with an example in the attached document.

You might be interested in
What are pixels that are the exact same between multiple frames called?
Oxana [17]

Answer:

the answer is temporal redundancy

Explanation:

Computer Definition. Pixels in two video frames that have the same values in the same location. Exploiting temporal redundancy is one of the primary techniques in video compression (see interframe coding). Contrast with spatial redundancy.

6 0
4 years ago
Dereck works for long hours on his computer. He frequently experiences physical strain by the end of the day because he does not
rjkz [21]
<span>keeping hands and wrists straight while typing</span>
3 0
3 years ago
Read 2 more answers
If you want to add text in an area of a slide where a content placeholder is not located, you can insert a(n) _______________.
bulgar [2K]
You can insert a text box ~ wubba lubba dub dub!
6 0
3 years ago
A hard drive that is running slowly may not have been properly?
Effectus [21]
Its probably out dated our its been over used.
7 0
3 years ago
Ano ang<br> rotasyon ng daigdig​
Degger [83]

Answer:  are you tying to ask a question

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
    15·2 answers
  • Which domain ending can only be used by educational institutions?
    12·1 answer
  • Universal Containers (UC) has decided to build a new, highly sensitive application on the Force platform. The security team at U
    11·1 answer
  • _____ is a method of computing that delivers secure, private, and reliable computing experiences based on sound business practic
    7·1 answer
  • Handouts are pages of your presentation that you print and distribute to your audience
    10·1 answer
  • 4.9 Code Practice: Question 3
    15·2 answers
  • You’ve been tossed into an insane asylum. What do you tell the people there to prove to them that you don’t belong inside?
    7·2 answers
  • For each problem listed below, use the drop-down menu to select the field of the professional who can help solve the issue.
    7·2 answers
  • My sister told me an extremely funny joke. what is the direct object for this sentence ?
    6·1 answer
  • Question 1 of 10
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!