we are given a file that has the following data: 6.9 100 0.9 200 0.6 300 0.3 150
ID: 3610424 • Letter: W
Question
we are given a file that has the following data:6.9
100 0.9
200 0.6
300 0.3
150 0.2
the first number represents intensity level= i
the first column under 6.9 represent Area and the second columnrepresents a coefficient representing surface type..
so we need to use the prototype
double read_data(double *i, double *A) which needs to read an inputfile silimar to the data above
and needs to calculate the total area A (100+200+300+150=750)
Also calculate weighted average: formula is C=[0.9*(totalA/0.9)*100+ 0.6*(totalA/0.6)*100........]-return this value to themain function
in the main function calculate Q= CiA
PLEASE HELP..will give LIEFESAVOR POINTS!!!!
Explanation / Answer
please rate - thanks that weight average formula has got to be wrong C=[0.9*(total A/0.9)*100+ 0.6*(totalA/0.6)*100........] same as C=A*100+A*100... code can easily be changed #include #include double read_data(double *, double *); int main() {double i,A,Q,C; FILE *fp; if(!(fp=fopen("text.txt","r"))) { printf(" Error opening file "); getch(); return 1; } C=read_data(&i, &A); if(C!=99.99) {Q=C*i*A; printf("intensity=%3.2lf TotalArea=%3.2lf Weighted average=%3.2lf Q=%3.2lf ",i,A,C,Q); } getch(); return 0; } double read_data(double *i, double *A) {FILE *fp; double area[4],wt[4],C=0,ti,tA; int j; if(!(fp=fopen("text.txt","r"))) {printf(" Error opening file "); return 99.99; } fscanf(fp,"%lf",&ti); tA=0; for(j=0;jRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.