answer.
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
MAVERICK
4 months ago
11

github Portfolio Balances An investor opens a new account and wants to invest in a number of assets. Each asset begins with a ba

lance of o, and its value is stored in an array using 7-based indexing. Periodically, a contribution is received and equal investments are made in a subset of the portfolio. Each contribution will be given by investment amount, start index, end index. Each investment in that range will receive the contribution amount. Determine the maximum amount invested in any one investment after all contributions
Computers and Technology
1 answer:
Rzqust [1K]4 months ago
6 0

This code serves to find out the highest amount invested

Explanation:

long maxValue(int n, int rounds_rows, int rounds_columns, int into rounds)

{

   // Variable declaration to hold

   // the highest investment amount.

   long max = 0;

   

   // Creating an array of size n,

   // to keep track of the n investments.

   long *investments = (long*)malloc(sizeof(long)*n);

   int i=0;  

   // Initialize all

   // investments to zero.

   for(i=0;i<n;i++)

   {

       investments[i] = 0;

   }

   i=0;

   // Execute the loop to

   // conduct the rounds.

   while(i<rounds_rows)

   {

       // Acquire the left value

       // for the current round.

       int left = rounds[i][0];

       

       // Acquire the right value

       // for this round.

       int right = rounds[i][1];

       // Get the contribution

       // for this round.

       int contribution = rounds[i][2];

       // Because user indexing is 1-based,

       // subtract 1 from left

       // and right as the program employs

       // 0-based indexing. The

       // array investments begins

       // at 0 and not 1.

       right = right - 1;

       int j=0;

       // Execute loop to distribute the

       // contribution across all investments

       // from left to right, inclusive.

       for(j=left; j<=right; j++)

       {

           investments[j] += contribution;

       }

       i++;

   }

   // Traverse the investments array

   // to locate the maximum value.

   max = investments[0];

   for(i=1; i<n;i++)

   {

       if(investments[i]>max)

       {

           max = investments[i];

       }

   }

   // Return the

   // highest investment.

   return max;  

}

You might be interested in
On the planet Sigma, robots excavate chunks of a very precious cristaline. These chunks can be divided into smaller part only on
Amiraneli [1052]

Answer:

Begin the algorithm by assessing the ship's weight. Load the crystalline material onto the ship. Verify if the weight equals the ship's weight plus k pounds of crystalline; if it is not enough, load additional crystalline. If there is an excess, discard the surplus crystalline. Upon meeting the required weight, the ship can depart for planet Sigma.

Explanation:

The algorithm consistently monitors the ship's weight while loading with the total of the ship's weight along with k pounds of crystalline. This method ensures that the ship carries the maximum feasible amount of crystalline to planet Sigma.

7 0
3 months ago
Define a new object in variable sculptor that has properties "name" storing "Michelangelo"; "artworks" storing "David", "Moses"
zubka84 [1067]

Answer:

String [] artworks = {"David","Moses","Bacchus"};

Sculptor sculptor = new Sculptor("Michaelangelo",artworks,

"March 6, 1475","February 18, 1564");

Explanation:

  • In order to successfully tackle this task;
  • You should create a class (Java is the chosen language) featuring fields for the name, an array of artworks (strings), the date of birth and the date of death.
  • Utilize a constructor to initialize these fields
  • In a separate class SculptorTest, within the main method, generate a String array artworks assigned to {"David","Moses","Bacchus"};
  • Then create a new object of the class using the code provided in the answer section.
  • Refer to the provided code for the complete class definition below:

public class Sculptor {

private String name;

private String [] artworks;

private String bornDate;

private String diedDate;

public Sculptor(String name, String[] artworks, String bornDate, String diedDate) {

this.name = name;

this.artworks = artworks;

this.bornDate = bornDate;

this.diedDate = diedDate;

}

}

//Test Class with a main method

class SculptorTest{

public static void main(String[] args) {

String [] artworks = {"David","Moses","Bacchus"};

Sculptor sculptor = new Sculptor("Michaelangelo",artworks,

"March 6, 1475","February 18, 1564");

}

}

6 0
3 months ago
Write a loop to populate the list user_guesses with a number of guesses. The variable num_guesses is the number of guesses the u
oksian1 [950]

Response:

num_guesses = int(input())

user_guesses = []

for i in range(num_guesses):

    x = int(input())

    user_guesses.append(x)

   

print(user_guesses)

Clarification:

This solution is given in Python

The initial line requests the user to input a number of guesses

num_guesses = int(input())

This line establishes an empty list

user_guesses = []

Inside this loop, each guess is taken from the user

for i in range(num_guesses):

In this line, each guess input by the user is processed

    x = int(input())

This adds the input to the list

    user_guesses.append(x)

Finally, this prints the collected user guesses    

print(user_guesses)

6 0
3 months ago
Other questions:
  • 9) If you are working on the part of 5-15 minutes, time-stamping (every 30 seconds) should start at: a) [00:05:00] b) [00:00:00]
    9·1 answer
  • Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in
    13·2 answers
  • This question involves a simulation of a two-player game. In the game, two simulated players each start out with an equal number
    7·1 answer
  • Sara is writing a program to input her monthly phone bills and output the month name and amount for the month with maximum amoun
    7·1 answer
  • What advantage do ExpressCard modules and USB adapters offer over expansion cards?
    5·1 answer
  • Laura has identified the job she wants, the skills needed for the position, and the areas she needs to improve in order to get i
    15·1 answer
  • A company has deployed four 48-port access layer switches to a switch block. For redundancy each access layer switch will connec
    14·1 answer
  • 1A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The
    5·1 answer
  • Which command backs up the single database called 'websites' to the file 'websites_backup.sql'?
    10·1 answer
  • Assume the input data is structured as follows: first there is a non-negative integer specifying the number of employee timeshee
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!