Last month Joe purchased some stock in Acme Software, Inc. Here are the details
ID: 3668443 • Letter: L
Question
Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase:
The number of shares that Joe purchased was 2,000.
When Joe purchased the stock, he paid $40.00 per share.
Joe paid his stock broker a commission that amounted to 3 percent of the amount he paid for the stock.
Two weeks later Joe sold the stock. Here are the details of the sale:
The number of shares that Joe sold was 2,000.
He sold the stock for $42.75 per share. '
He paid his stockbroker anothercommision that amounted to 3 percent of the amount he received for the stock.
Write a program that displays the following information:
The amount of money joe paid for the stock.
The amount of commision Joe paid his broker when he bought the stock.
The amount that Joe sold the stock for.
The amount of commision Joe paid his broker when he sold the stock.
Display the amount of money that Joe had left when he sold the stock and paid his broker (both times). If this amount is positive, then Joe made a profit. If the amount is negative, then Joe lost money
Explanation / Answer
Here I am going to write a programme in C
#include<stdio.h>
main(){
float shares=2000, paid_money, sold_at, cost_buy=42, cost_sold=42.75, percentage= 3, broker_commi_1, broker_commi_2, money_left;
/*amount of money joe paid for the stock */
paid_money = cost_buy * shares ;
printf("amount of money joe paid for the stock is :%f", paid_money); // it is 80000$
/* The amount of commision Joe paid his broker when he bought the stock */
broker_commi = (paid_money * 3)/100;
printf("The amount of commision Joe paid his broker when he bought the stock is :%f",broker_commi); //it is 2400$
/* The amount that Joe sold the stock for. */
sold_at = cost_sold * shares;
printf("The amount that Joe sold the stock for: %f",sold_at); // it is 85500$
/* The amount of commision Joe paid his broker when he sold the stock. */
broker_commi_2 = (sold_at * 3)/100;
/* here if joe only gives commission on profit amount that is 85500 - 80000 = 5500 then the broker_commi_2 would be less . because 3 percentage on profit of 5500 is 165$ only. your Question is littile bit confusing here about joe gave commission for entire sold amount or only profit amount. so i am considering here as joe giving cgain commission to entire sold amount. so it will be 2565. if my consideration is wrong replace
broker_commi_2 = (sold_at * 3)/100; with
float profit = sold_at - paid_money
broker_commi_2 = (profit*3 )/100 ; it is 165$
*/
printf("The amount of commision Joe paid his broker when he sold the stock:%f",broker_commi_2); //it is 2565$
/* amount of money that Joe had left when he sold the stock */
money_left = sold_at - broker_commi_1 - paid_money ;
/* it is 85500 - 2400 - 80000 = 3100 */
printf("amount of money that Joe had left when he sold the stock: %f",money_left);
/* amount of money that Joe had left when he paid his broker */
money_left = money_left - broker_commi_2 ; /* it is 3100 - 2565 = 535 */
if( money_left > 0){
printf("joe made profit of %f", money_left);
}
else{
printf("joe made loss of %f", -money_left);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.