Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: How to solve this problem in Programming

  1. #1
    Junior Member yugioh's Avatar
    Join Date
    Jul 2020
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy How to solve this problem in Programming

    I'm a beginner, please note, I have the following problem and I didn't find a solution on how to solve it, I'm trying to create this, what is the most appropriate way to solve this?

    A bank has a portfolio of thousands of trades and they need to be categorized.
    A trade is a commercial negotiation between a bank and a client.
    Each trade has a value that indicates the transaction amount in dollars and a text indicating if the client´s sector is "Public" or "Private". They implement the following interface:

    interface ITrade
    {
    double Value { get; }
    string ClientSector { get; }
    }

    Currently, there are three categories:
    LOWRISK: Trades with value less than 1,000,000 and client from Public Sector
    MEDIUMRISK: Trades with value greater than 1,000,000 and client from Public Sector
    HIGHRISK: Trades with value greater than 1,000,000 and client from Private Sector

    Imagine you receive a list of trades and you need to return a list of categories as below:
    input: List<ITrade> portfolio
    output: List<string> tradeCategories

    Example:
    Input:
    Trade1 {Value = 2000000; ClientSector = "Private"}
    Trade2 {Value = 400000; ClientSector = "Public"}
    Trade3 {Value = 500000; ClientSector = "Public"}
    Trade4 {Value = 3000000; ClientSector = "Public"}
    portfolio = {Trade1, Trade2, Trade3, Trade4}

    Output:
    tradeCategories = {"HIGHRISK", "LOWRISK", "LOWRISK", "MEDIUMRISK"}

    Keep in mind that category rules may be added/removed/modified in the future and be highly complex.
    Please write your answer in pseudo-code showing clearly what classes, interfaces, methods and design patterns you would create/use to solve this problem. Also, object oriented programming is appreciated.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to solve this problem in Programming

    What have you tried? Do you have any specific java programming questions about your assignment?

    Be sure to wrap all posted code in code tags.
    http://www.java-forums.org/misc.php?do=bbcode#code
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member yugioh's Avatar
    Join Date
    Jul 2020
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to solve this problem in Programming

    the problem:

    Each trade has a value that indicates the transaction amount in dollars and a text indicating if the client´s sector is "Public" or "Private". They implement the following interface:

    interface ITrade
    {
    double Value { get; }
    string ClientSector { get; }
    }

    Currently, there are three categories:
    LOWRISK: Trades with value less than 1,000,000 and client from Public Sector
    MEDIUMRISK: Trades with value greater than 1,000,000 and client from Public Sector
    HIGHRISK: Trades with value greater than 1,000,000 and client from Private Sector

    Imagine you receive a list of trades and you need to return a list of categories as below:
    input: List<ITrade> portfolio
    output: List<string> tradeCategories

    Example:
    Input:
    Trade1 {Value = 2000000; ClientSector = "Private"}
    Trade2 {Value = 400000; ClientSector = "Public"}
    Trade3 {Value = 500000; ClientSector = "Public"}
    Trade4 {Value = 3000000; ClientSector = "Public"}
    portfolio = {Trade1, Trade2, Trade3, Trade4}

    Output:
    tradeCategories = {"HIGHRISK", "LOWRISK", "LOWRISK", "MEDIUMRISK"}

    Keep in mind that category rules may be added/removed/modified in the future and be highly complex.
    Please write your answer in pseudo-code showing clearly what classes, interfaces, methods and design patterns you would create/use to solve this problem. Also, object oriented programming is appreciated.

    what I tried: I read this whole tutorial that explains what pseudo code is and uses java as an example: https://www.geeksforgeeks.org/how-to...a-pseudo-code/, but I don't know how to do it.

    some code: if (Trade.index(I).tradeValue < 1000000 and Trade.index(I).client ==< publicSector) Print (low risk)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to solve this problem in Programming

    Also posted at: https://www.dreamincode.net/forums/t...these-changes/

    Please read this: http://www.javaprogrammingforums.com...s-posting.html

    See my last post.

    I don't know how to do it.
    Can you ask your instructor for help with that?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member yugioh's Avatar
    Join Date
    Jul 2020
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to solve this problem in Programming

    my instructor is on a 30-day vacation, I really need help

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to solve this problem in Programming

    What have you tried?

    Be sure to wrap all posted code in code tags.

    --- Update ---

    Also posted here: https://coderanch.com/t/732272/java/...amming#3406346
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Can someone solve this Java programming Project
    By TheNwoLegend in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 29th, 2019, 02:10 PM
  2. please solve the problem
    By liz in forum Threads
    Replies: 1
    Last Post: February 6th, 2014, 05:27 AM
  3. Replies: 3
    Last Post: September 23rd, 2013, 10:51 AM
  4. how do i solve this programming problem in dr java?
    By jennavg in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 8th, 2013, 12:22 PM
  5. [SOLVED] Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
    By ihatejava in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 15th, 2012, 04:30 PM

Tags for this Thread