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
makvit [3.9K]
3 years ago
15

Implement a recursive java method to find the sum of the first n int's in a java int array. Max size 20.

Computers and Technology
1 answer:
oee [108]3 years ago
6 0

Solution:

public class SumOfArray {

private int[] a;

private int n;

private int result;

   public int sumOfArray(int[] a,int n) {

     this.a = a;//Max size is 20

     n = a.length;

     if (n == 0)  // base case

     return a[n];

     else

         return a[n] + sumOfArray(a, n-1);

     return result;

  } // End SumOfArray method

} // End SumOfArray Class  


You might be interested in
1
Dimas [21]

Answer:

C.  

Explanation:

Plato users

8 0
3 years ago
Trình bày chuẩn giao tiếp cổng USB
Viktor [21]
Wing wing wong wu wang
3 0
3 years ago
Ip address 10.10.20.0 255.255.255.224 how many host ip addresses are available in each subnet using this subnet mask?
Maksim231197 [3]
224 = 128 + 64 + 32, so that would mean each network could have 32 nodes. Subtract 2 for the network address and the multicast address, you would have 30 HOST addresses available.
3 0
4 years ago
• Write a method called generateTriangleNumbers(). This method will take in an integer x and will return an array of integers co
iris [78.8K]

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.

4 0
3 years ago
Read 2 more answers
Can someone tell me what all of these are?
Allisa [31]

Answer:

parts of a camera

Explanation:

5 0
4 years ago
Other questions:
  • When a user first authenticates with a Kerberos-based server, he/she will receive _________ Group of answer choices a ticket-gra
    10·1 answer
  • Successful attacks are commonly called ________. a. security incidents b. countermeasures c. both a and b d. neither a nor b
    10·1 answer
  • A group of users can perform certain operations on a shared workbook. Which option helps them to update and track changes in the
    14·1 answer
  • In which type of land contract does the seller earn interest on the difference between what the seller owes on an existing loan
    14·1 answer
  • Which of the following could not be represented by columns in the SPSS data editor? a. Levels of between-group variables. b. Lev
    11·2 answers
  • In which scenario would you view Word data in Excel?
    11·1 answer
  • If you have a 99% and you got a 50 on a test what is the grade please I will give brainless
    7·2 answers
  • Match the parts of the software applications with what they do.
    15·1 answer
  • Declare a struct of your choice (Employee, Student etc). Delcare a node for singly link list. Declare an ADT of this linklist. T
    7·1 answer
  • how is a two-dimensional array different from a traditional one dimensional array? From an ArrayList?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!