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]
3 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]3 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 determines the keystroke to open a cmos editor? how can you find this information?
Brums [2.3K]
<span>Determining the keystrokes of opening the cmos editor depends on the ram contained in the parameters in BIOS.It can be a very daunting task however made more accessible by instructions detailed in various ways by others.Research is needed.</span>
3 0
3 years ago
What command launches the remote desktop client for windows?
Ksju [112]
%windir%\system32\mstsc.exe

launches the RDP client.
7 0
3 years ago
Headphones are an example of _____.
katen-ka-za [31]
The Answer Is An Output Device 


3 0
3 years ago
Read 2 more answers
This is a device that enables computers to be connected to a network.
zhuklara [117]

The answer to your question is,

NIC - Network Interface Card

-Mabel <3

8 0
3 years ago
What is a fixed expense<br> everfi
Gelneren [198K]

Answer:

A fixed expense is an expense that has a constant total expense value (the total amount of the fixed expense) that remains the same (does not change) when there is a change in the number being managed, manufactured, or sold

Examples of fixed  expense includes; depreciation of assets, salaries of workers, payment for rental lease, and some utility payment, such as road users toll fees payment at a toll gate

Explanation:

8 0
2 years ago
Other questions:
  • What does a transistor do?
    13·2 answers
  • An ______ is a simplified image. [4 letters]​
    7·2 answers
  • Describe network in terms of the class computer lab
    14·1 answer
  • The most efficient way to perform data entry is to keep your hands on the keyboard and press _______ to move to the next cell in
    14·1 answer
  • In a Windows environment, __________ is a powerful tool that enables security administrators to share user and group definitions
    10·1 answer
  • Count positive and negative number and compute the average. The program will have the user input an unspecified number of intege
    6·1 answer
  • Which of the following countries have mixed-market economy
    5·1 answer
  • Drag each tile to the correct box.
    15·1 answer
  • Write any one method to delete a table in writer​
    11·1 answer
  • Commercial technical data and commercial software:_________.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!