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
How do you know how much space is on the computer
Vladimir79 [104]
Depending on which computer you have you can go into settings and check the data tab or it should be on the box how much it comes with :)
5 0
4 years ago
Read 2 more answers
________ are devices in a computer that are in either the on or off state
Vanyuwa [196]
The appropriate response is Electrical Switches. These are electromechanical gadgets that are utilized as a part of electrical circuits to control, recognize when frameworks are outside their working reaches, flag controllers of the whereabouts of machine individuals and work pieces, give a way to manual control of machine and process capacities, control lighting, et cetera.
6 0
4 years ago
You want some points? whoever answers first gets 48 points. no cap. better be quick.
LekaFEV [45]

Answer:

4

Explanation:

5 0
3 years ago
Read 2 more answers
A user saves a password on a website the user logs into from a desktop. Under which circumstances will the password be saved on
artcher [175]

Answer:

same encryption certificate

Explanation:

only logical xD

4 0
3 years ago
Which of the following is a quality of a mixed economy?
tekilochka [14]

Answer:

Image result for Which of the following is a quality of a mixed economy? 1. Businesses have complete control of what they import. 2. Individuals have complete control of what they export. 3.Leaders determine the wages of individuals without any input from businesses. 4. Government encourages free trade of specific products.

'One main characteristic of a mixed economy is the ownership of goods by both private and government/state-owned entities. Monopolies have the potential to occur in this type of economy, but the government closely monitors this. For the economy to be mixed, the government can control some parts but not all.

Explanation:

6 0
3 years ago
Other questions:
  • ​Which of the following languages is used to set the width of a media player, add borders, drop shadows, and apply filters and t
    7·1 answer
  • Which f the following is not a characteristic of igneous rock
    8·1 answer
  • Write a Program in C language using arrays:
    14·1 answer
  • Which command displays the contents of the NVRAM?
    13·1 answer
  • Gigantic Life Insurance is organized as a single domain. The network manager is concerned that dividing into multiple domains to
    15·1 answer
  • If your internet were to go out, what steps would you take to troubleshoot to restore your service?
    15·1 answer
  • Is there anyone that knows how to work in Microsoft Access and someone that could help me on my test at 11 30am?​
    7·1 answer
  • Waygate's residential Internet modem works well but is sensitive to power-line fluctuations. On average, this product hangs up a
    6·1 answer
  • Major findings of evolution of computers
    10·1 answer
  • Multiple choice:
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!