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
Does the security burden fall primarily on the user? On
liubo4ka [24]

Answer:

yes and no because of the security

Explanation:

yes and no because of the security

6 0
3 years ago
How do i use a computer (i'm 99999 years old)
AlekseyPX

Answer:

grandma?

Explanation:

is it you?

6 0
3 years ago
Read 2 more answers
I need help with humans need not apply for codeing
vampirchik [111]

Answer:

huge\color{blue}\boxed{The}\huge\color{pink}\boxed{Points

3 0
2 years ago
Read 2 more answers
Which statement about broadcasting a slideshow online is true?
9966 [12]

Answer: PowerPoint has a free, built-in service for broadcasting online.

Explanation:

The statement that's true about the broadcast of a slideshow online is that PowerPoint has a free, built-in service for broadcasting online.

Option 1 is wrong as all transitions are not properly displayed to the audience when broadcasting online.

Option 2 is wrong as broadcasting as slideshow online is an option for most PowerPoint users.

Option 3 is wrong because when broadcasting online, third party desktop sharing software isn't necessarily an option and it isn't a must that it must be used.

Therefore, the correct option is 4.

4 0
3 years ago
Read 2 more answers
From your fist impression, write down what first comes to mind as to what is good and bad about the way the device works.
nalin [4]

Answer:

xczczxczx

Explanation:

6 0
3 years ago
Other questions:
  • What does computer means?
    13·2 answers
  • Technology is often discovered by accident
    5·1 answer
  • Which of the following goals is likely to require funding? Check all that apply.
    6·2 answers
  • the part of the computer that contains the brain , or central processing unit , is also known the what ?
    12·1 answer
  • The standing toe touch is most likely to result in
    15·1 answer
  • What happens when the following code segment executes if test.txt does not exist?:<br> A,B,C,D?
    7·1 answer
  • A(n) ____________________ key is a key that is not reused, but rather is only used once, thus improving security by reducing the
    5·1 answer
  • What distinguishes Accenture as a holistic provider of Extended Reality (XR) services?.
    9·1 answer
  • The features used be of Computer that tell, it every field.​
    6·1 answer
  • Are programs that understand physics and/or hardware embedded? for example, one that uses finite-element methods to predict flui
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!