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
qwelly [4]
3 years ago
8

Implement a simplified version of a crypto broker platform. Initially, there is an array of users, with each user depositing onl

y cash - deposits[i] is the amount of cash the (i + 1)th user has deposited.
Assume that for now the platform contains just a single stock and all operations are done with this stock only. All operations are supposed to be in the same currency, and currency exchange is not supported for now.
The platform should support the following 3 types of operations:
"deposit " - deposits money to the specified user account.
"buy " - the specified user buys the specified amount of crypto at the specified price. The platform should make sure the user has enough money in their account to process the operation.
"sell " - the specified user sells the specified amount of crypto at specified price. The platform should make sure the user has enough cryptos in their account to process the operation.
Your task is to return an integer array representing the total amount of money in the specified user's account after each operation.
Example
For deposits = [9, 7, 12] and
operations = [
"buy 1 3 2",
"sell 1 4 10",
"deposit 2 12",
"buy 2 10 2",
"buy 2 6 3"
]
the output should be cryptoTrading(deposits, operations) = [3, 3, 19, 19, 1].
Let's consider all operations:
The user with user_id = 1 wants to buy 3 shares of the stock at price = 2 - the required amount of money is needed_money = 3 * 2 = 6. The user has 9 ≥ 6 units of money in their account, so this operation will be processed successfully. After this operation, the user has 3 units of money remaining.
The user with user_id = 1 wants to sell 4 shares of the stock at price = 10 - this operation will not be processed successfully because the user does not have 4 shares of the stock. Since the operation is not processed successfully, the user still has 3 units of money remaining.
The user with user_id = 2 deposits 12 units of money into their account. After this operation, the user has 19 units of money.
The user with user_id = 2 wants to buy 10 shares the stock at price = 2 - the required amount of money is needed_money = 10 * 2 = 20. The user has 19 < 20 units of money in their account, so this operation will not be processed successfully. The user still has 19 units of money remaining.
The user with user_id = 2 wants to buy 6 shares of the stock at price = 3 - the required amount of money is needed_money = 6 * 3 = 18. The user has 19 ≥ 18units of money, so this operation will be processed successfully. After this operation, the user has 1 unit of money remaining.
So, the output is [3, 3, 19, 19, 1].
Input/Output
[execution time limit] 0.5 seconds (cpp)
[input] array.integer deposits
An array of integers representing the amount of money (in cash) that users deposit to their accounts.
Guaranteed constraints:
1 ≤ deposits.length ≤ 104,
1 ≤ deposits[i] ≤ 105.
[input] array.string operations
An array of strings representing the operations described above. Specifically, it's guaranteed that:
In buy and sell operations - amount and price are integers.
In all operations - user_id will be integers between 1 to deposits.length.
After each operation, the total amount of money in each user's account will be an integer.
Guaranteed constraints:
1 ≤ operations.length ≤ 104.
[output] array.integer
An array of integers where the ith element of the array represents the total amount of money in the specified user's account after the ith operation.
PLEASE DO THIS IS JAVA or C++
vector cryptoTrading(vector deposits, vector operations) {
}
Computers and Technology
1 answer:
Salsk061 [2.6K]3 years ago
3 0
Jriririiekeekekkksks
You might be interested in
Question 3
goldfiish [28.3K]

Answer: Zero is output.

8 0
3 years ago
LAB: Convert to binary - methods
Georgia [21]

Answer:

import java.util.Scanner;

public class Lab{

  public static String integerToReverseBinary(int number)

  {

      String binary = "";

      if(number == 0){

          return "0";

      }

      while(number > 0)

      {

          int remainder = number % 2;

          number = number / 2;

          binary += Integer.toString(remainder);

      }

      return binary;

  }

 

  public static String reverseString(String wordString)

  {

      String binaryString = "";

      int length = wordString.length();

      for(int i = length -1 ; i >= 0 ; i--)

      {

          binaryString += wordString.charAt(i);

      }

      return binaryString;

  }

 

Explanation:

In the java source code, the Lab class is defined which has two methods, 'reverseString' and 'integerToReverseBinary'. The latter gets the argument from the former and reverses the content of its string value, then returns the new string value. The former gets the integer value and converts it to its binary equivalence for which are converted to strings and returned.

8 0
3 years ago
A.
blondinia [14]

Answer:

the electronic devices that are used for storing and processing data typically in binary from according to instructions given to it in a variable program . its major parts are 1 keyboard. mouse .monitor. cpu

Explanation:

i think this one is of a number

7 0
3 years ago
What help the ict in your life?and write own idea three or four sentence
My name is Ann [436]

Answer:

I am a software engineering student

computers have createed an impact in my life because through computers i work, I do research and many more

7 0
3 years ago
According to symbolic interaction theory, the internet has helped to remove:
DanielleElmas [232]

Answer:

According to symbolic  interaction theory, the internet has helped to remove:

(D) Time and space barriers.

Explanation:

  • The symbolic interaction theory is such theory which explains that language and symbols are the means of interaction in the social worlds. This theory tells us about the relationship between people in a society.
  • The option a is not correct as the internet has not remove the subculture rather it has provided safe space to it. Sub-culture refers to a group of special interest like group of a biker. Anyone can create their community on the internet.
  • The option b is also incorrect as internet has not remove interpersonal communication rather it has speed up this communication. It is a type of communication in which people communicate with each other via their expression of feelings, verbal and non-verbal means.
  • The option c is also incorrect as the inappropriate content has removed by internet rather now everyone can create content. But regulations and guidelines are being made. A lot of work has been to be done in this area.
  • The option d is correct as the internet has helped to remove the barriers of time and space. It has made this world a global village now anyone from any part of the world can talk to any person to other part of the world over the internet. They can create communities depending upon their interests. They can do business and many other things.
5 0
3 years ago
Other questions:
  • To edit the text in a SmartArt graphic, what must be done first?
    5·1 answer
  • Developers work together with customers and useras to define requirements and specify what the proposed system will do. If once
    9·1 answer
  • John Cleaver is the CEO of Tech World, which is a retail store that sells computers, monitors, cameras, televisions and many oth
    6·1 answer
  • Plz answer me will mark as brainliest​
    13·1 answer
  • What are five features of word 2016 you would use to make a brochure
    6·2 answers
  • You are using a crimper to attach an RJ-45 connector to a Cat 6 UTP cable. Your company requires that all cabling follow the TIA
    14·1 answer
  • How do you make computers or microwaves?
    13·1 answer
  • Which technology provides a solution to IPv4 address depletion by allowing multiple devices to share one public IP address
    13·1 answer
  • 6. By default,how the table headings are placed. (2 Points)
    6·1 answer
  • Write a 200 word essay about how a computer is made.<br><br>Good luck.​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!