Guest User

Untitled

a guest
Jul 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. char name[22];
  7. char date[14];
  8.  
  9. char ch=0;
  10. int ns=0;
  11. int r=0;
  12.  
  13. float bp=0,cp=0,yf=0,total=0,total2=0;
  14.  
  15. //task1
  16. memset(name, 0, 22);
  17. memset(date, 0, 14);
  18.  
  19. //initialize variables
  20. bp=0;
  21. cp=0;
  22. yf=0;
  23. total=0;
  24. ns=0;
  25.  
  26. printf("----------------------------\n");
  27.  
  28. printf("enter date of purchase for aviator: ");
  29. r=read(0, &date, 13);
  30.  
  31. name[r-1]=0;
  32. date[r-1]=0;
  33.  
  34. printf("enter number of shares purchased: ");
  35. scanf("%d", &ns);
  36.  
  37. printf("enter the buying price per share:");
  38. scanf("%f", &bp);
  39.  
  40. printf("enter the current price per share:");
  41. scanf("%f",&cp);
  42.  
  43. printf("enter the yearly fees of %s:", name);
  44. scanf("%f",&yf);
  45.  
  46. printf("----------------------------\n");
  47.  
  48. printf("Stock name: %s\n", name);
  49. printf("Purchase date: %s\n", date);
  50. printf("Buying price per share of %s $%0.2f\n", name, bp);
  51. printf("Current price per share of %s $%0.2f\n", name, cp);
  52. printf("Yearly fees of %s $%0.2f\n", name, yf);
  53. printf("Initial Cost: $%0.2f\n", ns*bp);
  54. printf("Current Cost: $%0.2f\n", ns*cp);
  55. printf("Profit: $%0.2f\n", ns*cp-ns*bp-yf);
  56.  
  57. total2+=(ns*cp-ns*bp-yf);
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. //task1
  73. memset(name, 0, 22);
  74. memset(date, 0, 14);
  75.  
  76. //initialize variables
  77. bp=0;
  78. cp=0;
  79. yf=0;
  80. total=0;
  81. ns=0;
  82.  
  83. printf("----------------------------\n");
  84.  
  85. printf("enter date of purchase for bonzo: ");
  86. r=read(0, &date, 13);
  87.  
  88. name[r-1]=0;
  89. date[r-1]=0;
  90.  
  91. printf("enter number of shares purchased: ");
  92. scanf("%d", &ns);
  93.  
  94. printf("enter the buying price per share:");
  95. scanf("%f", &bp);
  96.  
  97. printf("enter the current price per share:");
  98. scanf("%f",&cp);
  99.  
  100. printf("enter the yearly fees of %s:", name);
  101. scanf("%f",&yf);
  102.  
  103. printf("----------------------------\n");
  104.  
  105. printf("Stock name: %s\n", name);
  106. printf("Purchase date: %s\n", date);
  107. printf("Buying price per share of %s $%0.2f\n", name, bp);
  108. printf("Current price per share of %s $%0.2f\n", name, cp);
  109. printf("Yearly fees of %s $%0.2f\n", name, yf);
  110. printf("Initial Cost: $%0.2f\n", ns*bp);
  111. printf("Current Cost: $%0.2f\n", ns*cp);
  112. printf("Profit: $%0.2f\n", ns*cp-ns*bp-yf);
  113.  
  114. total2+=(ns*cp-ns*bp-yf);
  115.  
  116.  
  117.  
  118.  
  119.  
  120. //task1
  121. memset(name, 0, 22);
  122. memset(date, 0, 14);
  123.  
  124. //initialize variables
  125. bp=0;
  126. cp=0;
  127. yf=0;
  128. total=0;
  129. ns=0;
  130.  
  131. printf("----------------------------\n");
  132.  
  133. printf("enter date of purchase for cheery: ");
  134. r=read(0, &date, 13);
  135.  
  136. name[r-1]=0;
  137. date[r-1]=0;
  138.  
  139. printf("enter number of shares purchased: ");
  140. scanf("%d", &ns);
  141.  
  142. printf("enter the buying price per share:");
  143. scanf("%f", &bp);
  144.  
  145. printf("enter the current price per share:");
  146. scanf("%f",&cp);
  147.  
  148. printf("enter the yearly fees of %s:", name);
  149. scanf("%f",&yf);
  150.  
  151. printf("----------------------------\n");
  152.  
  153. printf("Stock name: %s\n", name);
  154. printf("Purchase date: %s\n", date);
  155. printf("Buying price per share of %s $%0.2f\n", name, bp);
  156. printf("Current price per share of %s $%0.2f\n", name, cp);
  157. printf("Yearly fees of %s $%0.2f\n", name, yf);
  158. printf("Initial Cost: $%0.2f\n", ns*bp);
  159. printf("Current Cost: $%0.2f\n", ns*cp);
  160. printf("Profit: $%0.2f\n", ns*cp-ns*bp-yf);
  161.  
  162. total2+=(ns*cp-ns*bp-yf);
  163.  
  164.  
  165.  
  166. //task1
  167. memset(name, 0, 22);
  168. memset(date, 0, 14);
  169.  
  170. //initialize variables
  171. bp=0;
  172. cp=0;
  173. yf=0;
  174. total=0;
  175. ns=0;
  176.  
  177. printf("----------------------------\n");
  178.  
  179. printf("enter date of purchase for downer: ");
  180. r=read(0, &date, 13);
  181.  
  182. name[r-1]=0;
  183. date[r-1]=0;
  184.  
  185. printf("enter number of shares purchased: ");
  186. scanf("%d", &ns);
  187.  
  188. printf("enter the buying price per share:");
  189. scanf("%f", &bp);
  190.  
  191. printf("enter the current price per share:");
  192. scanf("%f",&cp);
  193.  
  194. printf("enter the yearly fees of %s:", name);
  195. scanf("%f",&yf);
  196.  
  197. printf("----------------------------\n");
  198.  
  199. printf("Stock name: %s\n", name);
  200. printf("Purchase date: %s\n", date);
  201. printf("Buying price per share of %s $%0.2f\n", name, bp);
  202. printf("Current price per share of %s $%0.2f\n", name, cp);
  203. printf("Yearly fees of %s $%0.2f\n", name, yf);
  204. printf("Initial Cost: $%0.2f\n", ns*bp);
  205. printf("Current Cost: $%0.2f\n", ns*cp);
  206. printf("Profit: $%0.2f\n", ns*cp-ns*bp-yf);
  207.  
  208. total2+=(ns*cp-ns*bp-yf);
  209.  
  210.  
  211.  
  212. //task1
  213. memset(name, 0, 22);
  214. memset(date, 0, 14);
  215.  
  216. //initialize variables
  217. bp=0;
  218. cp=0;
  219. yf=0;
  220. total=0;
  221. ns=0;
  222.  
  223. printf("----------------------------\n");
  224.  
  225. printf("enter date of purchase for even: ");
  226. r=read(0, &date, 13);
  227.  
  228. name[r-1]=0;
  229. date[r-1]=0;
  230.  
  231. printf("enter number of shares purchased: ");
  232. scanf("%d", &ns);
  233.  
  234. printf("enter the buying price per share:");
  235. scanf("%f", &bp);
  236.  
  237. printf("enter the current price per share:");
  238. scanf("%f",&cp);
  239.  
  240. printf("enter the yearly fees of %s:", name);
  241. scanf("%f",&yf);
  242.  
  243. printf("----------------------------\n");
  244.  
  245. printf("Stock name: %s\n", name);
  246. printf("Purchase date: %s\n", date);
  247. printf("Buying price per share of %s $%0.2f\n", name, bp);
  248. printf("Current price per share of %s $%0.2f\n", name, cp);
  249. printf("Yearly fees of %s $%0.2f\n", name, yf);
  250. printf("Initial Cost: $%0.2f\n", ns*bp);
  251. printf("Current Cost: $%0.2f\n", ns*cp);
  252. printf("Profit: $%0.2f\n", ns*cp-ns*bp-yf);
  253.  
  254. total2+=(ns*cp-ns*bp-yf);
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263. //task2
  264. printf("----------------------------\n");
  265. printf("Total profit is: $ %0.2f\n", total2);
  266.  
  267. return 0;
  268. }
Add Comment
Please, Sign In to add comment