Language C Last picture it the print.txt file If you can email to me it would he
ID: 3911595 • Letter: L
Question
Language C Last picture it the print.txt file If you can email to me it would help a lot BGUTIERREZ2015@fau.edu Sprint LTE 8:33 AM 100% Goals (Requirements): In this project you will calculate the maximum profit you could have made by trading a single stock over a period of one month. You will assume that you bought rounded stock units (usually in hundreds, or tens) worth between $3000 and $5000 at the best possible"closing AFootnote " price during the period and sold it at the best possible "closing" price. You will assume that you are permitted to buy your units just once during this period and then sell it just once. You have to buy them before you can sell them (long trading only, no shorts) Example I could have bought 70 units of FSLR on 2018/06/11 for $51.82/unit for a total price of $3627.40, and sold it on 2018/06/14 $53.71/unit for a total proceeds of $3759.70 for a profit of $132.30. I did it just be inspection. This may not be the maximum profit I could have made. You can use the power of C language earn better profits. Even though in this example, I state the dates of the trade, you do not have to specify when you bought and when you sold. All you need to find is what price you paid at what price you sold, and calculate the profit you madeExplanation / Answer
here is your program : ---------->>>>>>>>
#include<stdio.h>
#define MAX 100
void banner(){
/* you can put here more information about the program when you define more function */
printf("This Program will get the price from a file and extract the information like minimum price , maximum price ");
}
double getMinPrice(double *pStockPrice,int size){
int i;
double result;
result = pStockPrice[0];
for(i = 1;i<size;i++){
if(result > pStockPrice[i]){
result = pStockPrice[i];
}
}
return result;
}
void getMaxPrice(double *pStockPrice,int size,double *pMaxPrice){
int i;
double result = pStockPrice[0];
for(i = 1;i<size;i++){
if(result < pStockPrice[i]){
result = pStockPrice[i];
}
}
*pMaxPrice = result;
}
void test(){
FILE *fp;
double *pStockPrice = (double *)malloc(sizeof(double)*MAX);
int size = 0;
char file[30];
printf(" Enter The Price File Name : ");
scanf("%s",&file);
fp = fopen(file,"r");
if(fp == NULL){
printf("File Opening Error");
exit(-1);
}
for(size = 0;size < MAX;size++){
if(feof(fp)){
break;
}
fscanf(fp,"%lf",&pStockPrice[size]);
}
fclose(fp);
size--;
double max = 0;
getMaxPrice(pStockPrice,size,&max);
double min;
min = getMinPrice(pStockPrice,size);
printf(" Minimum Price = %0.2lf Maximum Price = %0.2lf",min,max);
}
int main(){
test();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.