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 setting in Blender allows you to see the Graph Editor?
Brut [27]

The answer is b It allows you to modify the animation for any properties using F-Curves. The Graph editor has two modes, F-Curve for Actions, and Drivers for Drivers. Both are very similar in function.

3 0
3 years ago
Question of Computer science​
PtichkaEL [24]

Answer:

a)None

b)All

this is ur answer from my opinion

5 0
2 years ago
How do you start using the Internet?
fgiga [73]

Answer:

it's

D. open web browser

3 0
2 years ago
Read 2 more answers
Write the definitions for three function named max. Each receives two parameters, of the same type, and returns the larger of th
GenaCL600 [577]

Answer:

The method definition to this question can be given as:

Method definition:

double max(double x, double y)  //define method with double parameter  

{

if (x>=y)    //check condition.

return x;  //return value

else

return y;     //return value

}

double max(int x, int y)    //define method with integer parameter

{

if (x>=y)    //check condition

return x;    //return value

else

return y;  //return value

}

double max(char x, char y)   //define method with char parameter

{

if (x>=y)    //check condition

return x;    //return value

else

return y;    //return value

}

Explanation:

The above method definition can be described as below:

  • In the first method definition first, we define a method that is "max()". In this method we pass two variables as a parameter that is "x and y" and the datatype of this is double. Then we use a conditional statement. In the if block we check if variable x is greater then equal to y then it will return x else it will return y.  
  • In the second method definition, we define a method that is same as the first method name but in this method, we pass two integer variable that is "x and y". Then we use a conditional statement. In the if block we check if variable x is greater then equal to y then it will return x else it will return y.
  • In the third method definition, we define a method that is same as the first and second method name but in this method, we pass two char variable that is "x and y". Then we use a conditional statement. In the if block we check if variable x is greater then equal to y then it will return x else it will return y.
8 0
3 years ago
Which Ribbon contains the paragraph attributes?<br><br> Home<br> Insert<br> Review<br> View
Lemur [1.5K]
The Home ribbon contains the Paragraph attributes
7 0
3 years ago
Read 2 more answers
Other questions:
  • Being tired has very similar effects on the body as what
    7·1 answer
  • How does an employer judge a candidate?<br> The employer judge's the candidate's ? for a job.
    12·1 answer
  • When creating a scene in Blender, you should change Blender Render to ______ to create the best lighting option?
    15·1 answer
  • According to the video, what education and experience do employers look for in Reporters and Correspondents? Check all that appl
    10·2 answers
  • Shelly tells a friend that her computer needs to be fixed because it has been producing a lot of heat and is smoking. Where is t
    10·1 answer
  • Which would you trade on a stock exchange? A: Shares B: Bonds C: Annuities
    6·2 answers
  • a marketing company is setting up a new office in the city. which type of contract should they sign for periodic maintenance of
    15·1 answer
  • Ew<br>subject: Computer<br>11101÷101<br> binary operations<br>​
    7·1 answer
  • Write a Python program (rainfall.py) to collect data and calculate the average rainfall over a period of years. The program shou
    11·1 answer
  • ________ is interpreted. Group of answer choices A. Python B. C C. C D. Ada E. Pascal
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!