Heres what I have so far:
/* Preprocessor directives */
#include <stdio.h>
#include <math.h>
#define pi 3.14159
#define inputfile "c:\\engr 200\\oil_explore.txt"
#define outputfile "c:\\engr 200\\oil_report.txt"
/* Main function */
int main(void)
{
/* Declare variables */
double ratio, depth, ideal_charge, length, weight, number_sticks,
wellsite;
int i;
FILE *explore, *report;
/* Open input file */
explore = fopen(inputfile,"r");
report = fopen(outputfile,"w");
/* Verify input file */
if(explore == NULL)
{
printf("\n\nERROR OPENING INPUT FILE\n\nPROGRAM
TERMINATED\n\n");
return 0;
}
/* Read control number from input file */
fscanf(explore,"%lf,%lf",&wellsite,&depth);
length = 1;
weight = 2;
/* Print main headings to computer screen */
printf("******************************************");
printf("\n DAILY DRILLING REPORT"
"\n\n SITE DEPTH IDEAL POWDER NUMBER OF STICKS"
"\n ID (ft) (lbs) ");
/* Read x-y coordinates, compute polar coordinates, and print
results */
while(wellsite != -999.0 && depth != -999.0)
{
/*fscanf(explore, "%i,%i", &wellsite,&depth);*/
ratio = depth/3.0;
ideal_charge = ratio/length*weight;
number_sticks = ratio/length;
if(depth <= 30.0)
printf("\n%5.1f %5.1f HOLE TOO SHALLOW FOR
BLASTING",wellsite,depth,ideal_charge,number_sticks);
else
{
if(depth>30.0)
printf("\n%5.1f %5.1f %8.3f
%8.3f",wellsite,depth,ideal_charge,
number_sticks);
}
fscanf(explore,"%lf,%lf",&wellsite,&depth);
}
printf("\n******************************************\n\n");
/* Close input file */
fclose(explore);
fclose(report);
/* Exit program */
return 0;
}
/******************************************************************************/
Given below is the completed code for the question. Please do rate the answer if it helped. Thank you.
#include <stdio.h>
#include <math.h>
#define pi 3.14159
#define inputfile "c:\\engr 200\\oil_explore.txt"
#define outputfile "c:\\engr 200\\oil_report.txt"
/* Main function */
int main(void)
{
/* Declare variables */
double ratio, ideal_charge, length, weight;
int number_sticks, depth, wellsite;
int i;
FILE *explore, *report;
/* Open input file */
explore = fopen(inputfile,"r");
report = fopen(outputfile,"w");
/* Verify input file */
if(explore == NULL)
{
printf("\n\nERROR OPENING INPUT
FILE\n\nPROGRAM TERMINATED\n\n");
return 0;
}
/* Read control number from input file */
fscanf(explore,"%lf,%lf",&length,&weight);
/* Print main headings to computer screen */
fprintf(report,
"******************************************");
fprintf(report, "\n DAILY DRILLING REPORT");
fprintf(report, "\n\n %7s %7s %15s %20s", "SITE",
"DEPTH", "IDEAL POWDER" ,"NUMBER OF STICKS");
fprintf(report, "\n %7s %7s %12s", "ID" ,"(ft)",
"(lbs)");
fscanf(explore, "%d,%d", &wellsite,
&depth);
while(wellsite != -999 && depth != -999)
{
ratio = depth/3.0;
ideal_charge =
ratio/length*weight;
number_sticks = (int)
ceil(ratio/length);
if(depth <= 30)
fprintf(report,
"\n%7d %7d HOLE TOO SHALLOW FOR BLASTING",wellsite,depth);
else
{
fprintf(report,
"\n%7d %7d %15.3f %20d",wellsite,depth,ideal_charge,
number_sticks);
}
fscanf(explore,
"%d,%d",&wellsite,&depth);
}
fprintf(report,
"\n******************************************\n\n");
/* Close input file */
fclose(explore);
fclose(report);
printf("\nPlease check the report %s",
outputfile);
/* Exit program */
return 0;
}
/******************************************************************************/
Heres what I have so far: /* Preprocessor directives */ #include <stdio.h> #include <math.h> #define pi...
INTRODUCTION: Oil exploration is being conducted by drilling holes and blasting the ground with specific amounts of dynamite to generate seismic readings that can be interpreted. To obtain useful seismic readings, a specific ratio between the amount of dynamite and the depth of the hole is needed. The ideal powder charge to depth-of-hole ratio is 1:3. For blasting operations, each stick of dynamite will be 1.5 feet long and will weigh 6 pounds. Ideally, we would use the exact amount...
#include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort, search // Define computeAvg here // Define findMax here // Define findMin here // Define selectionSort here ( copy from zyBooks 11.6.1 ) // Define binarySearch here int main(void) { // Declare variables FILE* inFile = NULL; // File pointer int singleNum; // Data value read from file int valuesRead; // Number of data values read in by fscanf int counter=0; // Counter of...