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
ozzi
3 years ago
10

• Write a method called generateTriangleNumbers(). This method will take in an integer x and will return an array of integers co

ntaining the first x triangle numbers. The nth triangle number is the sum of 1 + 2 + 3 + 4...(n − 1) + n. o generateTriangleNumbers(3) returns the array {1,3,6} o generateTriangleNumber(1) returns the array {1} o generateTriangleNumbers(7) returns the array {1, 3, 6, 10, 15, 21, 28}

Computers and Technology
2 answers:
iris [78.8K]3 years ago
4 0

Answer:

Check the explanation

Explanation:

//GenerateTriangleNumbers.java

import java.util.Arrays;

import java.util.Scanner;

public class GenerateTriangleNumbers {

   public static int[] generateTriangleNumbers(int x){

       int arr[] = new int[x];

       int sum = 0;

       for(int i = 1;i<=x;i++){

           sum += i;

           arr[i-1] = sum;

       }

       return arr;

   }

   public static void main( String [] args ){

       int n;

       Scanner in = new Scanner(System.in);

       System.out.print("Enter n: ");

       n = in.nextInt();

       System.out.println(Arrays.toString(generateTriangleNumbers(n)));

   }

}

Kindly check the attached image below for the code output.

Stolb23 [73]3 years ago
4 0

Answer:

See explaination

Explanation:

/GenerateTriangleNumbers.java

import java.util.Arrays;

import java.util.Scanner;

public class GenerateTriangleNumbers {

public static int[] generateTriangleNumbers(int x){

int arr[] = new int[x];

int sum = 0;

for(int i = 1;i<=x;i++){

sum += i;

arr[i-1] = sum;

}

return arr;

}

public static void main( String [] args ){

int n;

Scanner in = new Scanner(System.in);

System.out.print("Enter n: ");

n = in.nextInt();

System.out.println(Arrays.toString(generateTriangleNumbers(n)));

}

}

You might be interested in
A red bullet in a microflow indicates: a. that the microflow has been completed b. that the microflow contains errors c. that on
Viefleur [7K]

Answer:

d. an end point of the microflow mendix

Explanation:

In Computer programming, Microflows can be defined as a visual representation of textual program codes based on the Business Process Model and Notation (BPMN), it enables users to express the logic of application.

It is capable of performing various actions such as creating and updating objects, showing pages and making choices.

Microflows cannot be used in offline apps as it basically runs in the runtime server.

A red bullet in a microflow indicates an end point of the microflow mendix.

8 0
3 years ago
Why is Thomas Jefferson considered an accomplished man , or a Renaissance man?​
lesantik [10]
The term “Renaissance man” means for a very clever person to be good at many different things.
4 0
3 years ago
Looking at the example below is the type value equal to a string or an integer?
Simora [160]
B. Integer I think that’s the answer
5 0
3 years ago
Read 2 more answers
Which among the following is a fraudulent or deceptive act designed to trick individuals into spending time or money for little
ivanzaharov [21]

Answer:

A. Internet scams.

Explanation:

Internet scams is a fraudulent or deceptive act designed to trick individuals into spending time or money for little or no return through the use of a cloud service or the internet. Some examples of an internet scam are phishing scams, email spams, credit card scam, etc. It is simply centred around the provision of false information or misrepresentation of another party for the sole purpose of theft.

Hence, an internet scam is an illegal means of obtaining things from people and such is a cyber crime that is punishable by law.

6 0
3 years ago
What is the main difference between a shape and an icon?
otez555 [7]

Answer:

a.

Explanation:

you can size and position a shape but not an icon

7 0
2 years ago
Other questions:
  • Which type of media would be best for showing global trade routes?
    7·2 answers
  • Anna is making a presentation on the solar system. She wants to emphasize the planet names as they appear one by one on the pres
    11·1 answer
  • What is a help desk
    15·1 answer
  • What is the purpose of the Chart feature in Word?
    10·2 answers
  • In this chapter, you saw an example of how to write an algorithm that determines whether a number is even or odd. Write a progra
    6·2 answers
  • Someone asks you for help with a computer that hangs at odd times. You turn it on and work for about 15 minutes, and then the co
    10·1 answer
  • Finish the code where it says //YOUR CODE HERE
    11·1 answer
  • A large company such as a retail store or airline reservation system uses a ______ computer that acts as the central computer in
    13·1 answer
  • Consider the following code segment. How many unique new (do not count the starting process) processes are created? (you may wan
    6·1 answer
  • Why should you make sure the paper being used in a printer is dry and not damp?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!