If the company invests 100,000 USD or less, their profit will be based on 75,000 USD as  first 25,000 USD goes to set up the business in the first place. For the first 100,000 USD,  the profit margin is low: 4.5%. Therefore, for every 100 dollar they spend, they get a profit  of 4.5 dollar.  For an investment greater than 100,000 USD, for the first 100,000 USD (actually on 75,000  USD as 25,000 is the setup cost), the profit margin is 4.5% whereas for the rest, it goes up to  8%. For example, if they invest 250,000 USD, they will get an 8% profit for the 150,000  USD. In addition, from the rest 100,000 USD, 25,000 is the setup cost and there will be a  4.5% profit on the rest 75,000. The investment will always be greater

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

If the company invests 100,000 USD or less, their profit will be based on 75,000 USD as  first 25,000 USD goes to set up the business in the first place. For the first 100,000 USD,  the profit margin is low: 4.5%. Therefore, for every 100 dollar they spend, they get a profit  of 4.5 dollar. 

For an investment greater than 100,000 USD, for the first 100,000 USD (actually on 75,000  USD as 25,000 is the setup cost), the profit margin is 4.5% whereas for the rest, it goes up to  8%. For example, if they invest 250,000 USD, they will get an 8% profit for the 150,000  USD. In addition, from the rest 100,000 USD, 25,000 is the setup cost and there will be a  4.5% profit on the rest 75,000. The investment will always be greater or equal to 25,000 and multiple of 100. 

Complete the RECURSIVE methods below that take an array of integers (investments)  and an iterator (always sets to ZERO(‘0’) when the method is initially called) and prints the profit for the corresponding investment. You must avoid the loop and multiplication (‘*’)  operator. 

 

**Please explain how the bolded parts of this code are working. And please do not submit yet another code for me to understand. Please explain in words!!! **

class FinalQ:
    def print(self,array,idx):
        if(idx<len(array)):
            profit = self.calcProfit(array[idx])
            print(str(idx+1) + ". Investment: " + str(array[idx]) + "; Profit: " + str(profit))
            self.print(array, idx+1)           

    def calcProfit(self,investment):
        if investment <= 25000:
           return 0.0
        else:
            val = investment - 100000
            val = val / 100
            val = val + val + val + val + val + val + val + val

            return val + 3375.0      

#Testing
array = [25000,100000,250000,350000]
f = FinalQ()
f.print(array, 0)

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY