Answer:
#here is code in python.
#read number of shares
num_share = int(input("Enter number of shares:"))
#read purchase price
buy_p = float(input("Enter purchase price:"))
#read sell price
sell_p = float(input("Enter sale price:"))
#total buying cost
buy_cost=buy_p*1.03*num_share
#total selling cost
sell_cost=sell_p*0.97*num_share
#if net profit
if(sell_cost>buy_cost):
print("After the transaction, you made " +str(sell_cost-buy_cost)+ " dollars.")
#if net loss
else:
print("After the transaction, you lost " +str(buy_cost-sell_cost)+ " dollars.")
Explanation:
Read the total number of shares from user.Then read buying price of a share and selling price of a share.Then calculate total buying cost including commission.Calculate total selling cost excluding the commission.If total buying cost is greater than total selling cost the print the profit else print the loss in the transaction.
Output:
Enter number of shares:10
Enter purchase price:10
Enter sale price:10
After the transaction, you lost 6.0 dollars.
Answer and explanation :
the three control problems associated with competing process are
- MUTUAL EXCLUSION : We know that some resources are shareable and some are not shareable. which means only one process can access the resource at a time this type of resources are called critical resources this code can be access at only one process at a time. the other process if required to access should not be allowed
- DEADLOCK: this hold the process without complete for example suppose there are two resources R1 and R2 and two process P1 and P2 and P1 use R1 and P2 use R2 but after some time when P1 needs R2 but R2 is not available as it is used by P2 so the all process will be on hold
- STARVATION : when priorities are given to the process as high priorities and low priorities. And high priorities process always competing then low priorities process have to wait for very long time this is called starvation