Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Heres what I have so far: /* Preprocessor directives */ #include #include #define pi 3.14159 #define inputfile c:engr 200oil_explore.txt #define outputfile c:engr 200oil_report.txt /* Main

image text in transcribedimage text in transcribedimage text in transcribed

Heres what I have so far:

/* Preprocessor directives */ #include #include #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(" ERROR OPENING INPUT FILE PROGRAM TERMINATED "); 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(" DAILY DRILLING REPORT" " SITE DEPTH IDEAL POWDER NUMBER OF STICKS" " 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(" %5.1f %5.1f %8.3f %8.3f",wellsite,depth,ideal_charge, number_sticks); } fscanf(explore,"%lf,%lf",&wellsite,&depth); } printf(" ****************************************** "); /* Close input file */ fclose(explore); fclose(report); /* Exit program */ return 0; } /******************************************************************************/

INTRODUCTION: You are an engineer working for an oil company, and oil exploration is being conducted by drilling holes and blasting with specific amounts of dynamite. 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 the blasting operations, each stick of dynamite will have a specified length in feet and a specified weight in pounds. The governing equations are: ratio = depth/3.0 ideal_charge = ratio/length*weight number_sticks = ratio/length (this must be an integer computation) where: ratio is the computed powder charge to depth of hole. ideal_charge is the computed ideal powder charge in pounds. number_sticks is the computed number of sticks based on length. length is the length of each dynamite stick in feet. weight is the weight of each dynamite stick in pounds. An input data file called oil explore contains exploration information for each well site. The first record line contains the dynamite length and weight values respectively. Each remaining record line has two integer numbers, where the first number is the well site number and the second number is the hole depth in feet. The input file is comma delimited. ASSIGNMENT: Using only the techniques and procedures demonstrated and presented in class, write a C program that will read the required values from the input file, compute the hole depth ratio, the ideal charge, and the actual number of sticks. Use a while loop to control the reading, computing, and printing operations. Your program will produce a report in tabular format. Page 2 shows the output format style. Print the table to the computer screen and to an output file called oil report. When verifying if the input file exists, use the following print statement to display a message to the computer screen only. printf(" ERROR READING INPUT FILE PROGRAM TERMINATED "); Once the program is working, modify the program as follows: If the hole depth is less than or equal to 30 feet print the well site number, the well depth, and the message "HOLE TOO SHALLOW FOR BLASTING", else print the well site number, the well depth, the ideal powder, and the number of dynamite sticks. OUTPUT FORMAT: * * DAILY DRILLING REPORT NUMBER OF STICKS SITE ID xxxx DEPTH (ft) xxx IDEAL POWDER (lbs) xxx.xx xxx xxxx xxx HOLE TOO SHALLOW FOR BLASTING xxxx XXX XXX.XX ***************************** XXX ***************** FILE PATHS: Before submitting your C source program to Blackboard, make sure that you set your file paths in your program in the preprocessor directives section as follows: #define input file "u:\\engr 200\\oil explore.txt" #define outputfile "u:\\engr 200loil_report.txt" 2.8,5.8 1715, 100 5858, 98 987,38 3647,59 1834, 62 719, 243 5288, 27 2648,31 1328, 175 -999,-999

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Become familiar with coupling, cohesion, and connascence.

Answered: 1 week ago

Question

etermine the relative solubilities of the following compounds

Answered: 1 week ago

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago