Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.22 KB | None | 0 0
  1. //Program set 3
  2. //Written by Chantz Perreault
  3. //ID 1093906
  4. //CS36 September 13, 2017
  5. #include <stdio.h>
  6.  
  7. int main()
  8. {
  9. //Declare
  10. int NS1, NS2, NS3, NS4, NS5;
  11. float BP1, BP2, BP3, BP4, BP5, CP1, CP2, CP3, CP4, CP5, YF1, YF2, YF3, YF4, YF5, sum;
  12. float IC1, IC2, IC3, IC4, IC5, CC1, CC2, CC3, CC4, CC5, profit1, profit2, profit3, profit4, profit5;
  13. char name1 [11];
  14. char name2 [11];
  15. char name3 [11];
  16. char name4 [11];
  17. char name5 [11];
  18. // Buying price per share, current price per share, yearly fees
  19.  
  20. //Input
  21. printf("Enter name of first stock: ");
  22. gets(name1);
  23. printf("Enter name of second stock: ");
  24. gets(name2);
  25. printf("Enter name of third stock: ");
  26. gets(name3);
  27. printf("Enter name of fourth stock: ");
  28. gets(name4);
  29. printf("Enter name of fifth stock: ");
  30. gets(name5);
  31. printf("Enter number of shares: ");
  32. scanf("%d,%d,%d,%d,%d", &NS1, &NS2, &NS3, &NS4, &NS5);
  33. printf("Enter buying price per share: ");
  34. scanf("%f,%f,%f,%f,%f", &BP1, &BP2, &BP3, &BP4, &BP5);
  35. printf("Enter current price per share: ");
  36. scanf("%f,%f,%f,%f,%f", &CP1, &CP2, &CP3, &CP4, &CP5);
  37. printf("Enter yearly fees: ");
  38. scanf("%f,%f,%f,%f,%f", &YF1, &YF2, &YF3, &YF4, &YF5);
  39.  
  40.  
  41. //Calculation
  42. IC1 = NS1 * BP1;
  43. IC2 = NS2 * BP2;
  44. IC3 = NS3 * BP3;
  45. IC4 = NS4 * BP4;
  46. IC5 = NS5 * BP5;
  47. CC1 = NS1 * CP1;
  48. CC2 = NS2 * CP2;
  49. CC3 = NS3 * CP3;
  50. CC4 = NS4 * CP4;
  51. CC5 = NS5 * CP5;
  52. profit1 = CC1 - IC1 - YF1;
  53. profit2 = CC2 - IC2 - YF2;
  54. profit3 = CC3 - IC3 - YF3;
  55. profit4 = CC4 - IC4 - YF4;
  56. profit5 = CC5 - IC5 - YF5;
  57. sum = profit1 + profit2 + profit3 + profit4 + profit5;
  58.  
  59. //Output
  60. printf("-------------------------------------\n");
  61. printf("Stock Name: \%s                     |\n", name1);
  62. printf("Initial Cost:$ \%.2f              |\n", IC1);
  63. printf("Current Cost:$ \%.2f              |\n", CC1);
  64. printf("Profit:$ \%.2f                     |\n", profit1);
  65. printf("------------------------------------\n");
  66. printf("-------------------------------------\n");
  67. printf("Stock Name: \%s                  |\n", name2);
  68. printf("Initial Cost:$ \%.2f              |\n", IC2);
  69. printf("Current Cost:$ \%.2f              |\n", CC2);
  70. printf("Profit:$ \%.2f                     |\n", profit2);
  71. printf("------------------------------------\n");
  72. printf("-------------------------------------\n");
  73. printf("Stock Name: \%s               |\n", name3);
  74. printf("Initial Cost:$ \%.2f              |\n", IC3);
  75. printf("Current Cost:$ \%.2f             |\n", CC3);
  76. printf("Profit:$ \%.2f                    |\n", profit3);
  77. printf("------------------------------------\n");
  78. printf("-------------------------------------\n");
  79. printf("Stock Name: \%s                 |\n", name4);
  80. printf("Initial Cost:$ \%.2f              |\n", IC4);
  81. printf("Current Cost:$ \%.2f              |\n", CC4);
  82. printf("Profit:$ \%.2f                      |\n", profit4);
  83. printf("------------------------------------\n");
  84. printf("-------------------------------------\n");
  85. printf("Stock Name: \%s                   |\n", name5);
  86. printf("Initial Cost:$ \%.2f              |\n", IC5);
  87. printf("Current Cost:$ \%.2f              |\n", CC5);
  88. printf("Profit:$ \%.2f                     |\n", profit5);
  89. printf("------------------------------------\n");
  90. printf("The total profit of all the stocks is: \%.2f ", sum);
  91.  
  92.  
  93. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement