Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program set 3
- //Written by Chantz Perreault
- //ID 1093906
- //CS36 September 13, 2017
- #include <stdio.h>
- int main()
- {
- //Declare
- int NS1, NS2, NS3, NS4, NS5;
- float BP1, BP2, BP3, BP4, BP5, CP1, CP2, CP3, CP4, CP5, YF1, YF2, YF3, YF4, YF5, sum;
- float IC1, IC2, IC3, IC4, IC5, CC1, CC2, CC3, CC4, CC5, profit1, profit2, profit3, profit4, profit5;
- char name1 [11];
- char name2 [11];
- char name3 [11];
- char name4 [11];
- char name5 [11];
- // Buying price per share, current price per share, yearly fees
- //Input
- printf("Enter name of first stock: ");
- gets(name1);
- printf("Enter name of second stock: ");
- gets(name2);
- printf("Enter name of third stock: ");
- gets(name3);
- printf("Enter name of fourth stock: ");
- gets(name4);
- printf("Enter name of fifth stock: ");
- gets(name5);
- printf("Enter number of shares: ");
- scanf("%d,%d,%d,%d,%d", &NS1, &NS2, &NS3, &NS4, &NS5);
- printf("Enter buying price per share: ");
- scanf("%f,%f,%f,%f,%f", &BP1, &BP2, &BP3, &BP4, &BP5);
- printf("Enter current price per share: ");
- scanf("%f,%f,%f,%f,%f", &CP1, &CP2, &CP3, &CP4, &CP5);
- printf("Enter yearly fees: ");
- scanf("%f,%f,%f,%f,%f", &YF1, &YF2, &YF3, &YF4, &YF5);
- //Calculation
- IC1 = NS1 * BP1;
- IC2 = NS2 * BP2;
- IC3 = NS3 * BP3;
- IC4 = NS4 * BP4;
- IC5 = NS5 * BP5;
- CC1 = NS1 * CP1;
- CC2 = NS2 * CP2;
- CC3 = NS3 * CP3;
- CC4 = NS4 * CP4;
- CC5 = NS5 * CP5;
- profit1 = CC1 - IC1 - YF1;
- profit2 = CC2 - IC2 - YF2;
- profit3 = CC3 - IC3 - YF3;
- profit4 = CC4 - IC4 - YF4;
- profit5 = CC5 - IC5 - YF5;
- sum = profit1 + profit2 + profit3 + profit4 + profit5;
- //Output
- printf("-------------------------------------\n");
- printf("Stock Name: \%s |\n", name1);
- printf("Initial Cost:$ \%.2f |\n", IC1);
- printf("Current Cost:$ \%.2f |\n", CC1);
- printf("Profit:$ \%.2f |\n", profit1);
- printf("------------------------------------\n");
- printf("-------------------------------------\n");
- printf("Stock Name: \%s |\n", name2);
- printf("Initial Cost:$ \%.2f |\n", IC2);
- printf("Current Cost:$ \%.2f |\n", CC2);
- printf("Profit:$ \%.2f |\n", profit2);
- printf("------------------------------------\n");
- printf("-------------------------------------\n");
- printf("Stock Name: \%s |\n", name3);
- printf("Initial Cost:$ \%.2f |\n", IC3);
- printf("Current Cost:$ \%.2f |\n", CC3);
- printf("Profit:$ \%.2f |\n", profit3);
- printf("------------------------------------\n");
- printf("-------------------------------------\n");
- printf("Stock Name: \%s |\n", name4);
- printf("Initial Cost:$ \%.2f |\n", IC4);
- printf("Current Cost:$ \%.2f |\n", CC4);
- printf("Profit:$ \%.2f |\n", profit4);
- printf("------------------------------------\n");
- printf("-------------------------------------\n");
- printf("Stock Name: \%s |\n", name5);
- printf("Initial Cost:$ \%.2f |\n", IC5);
- printf("Current Cost:$ \%.2f |\n", CC5);
- printf("Profit:$ \%.2f |\n", profit5);
- printf("------------------------------------\n");
- printf("The total profit of all the stocks is: \%.2f ", sum);
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement