Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can somebody help me, I will rate right away its for C++ INTRODUCTION: You are a

ID: 3890402 • Letter: C

Question

Can somebody help me, I will rate right away its for C++

INTRODUCTION:

You are an engineer working for the Black-Gold oil company. 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 ration is 1:3. For the blasting operations, each stick of dynamite will be 2 feet long and will weigh 5 pounds. Since the actual powder charge will generally not be equal to the ideal powder charge, compute the actual powder charge in 5 pound increments.

Here is an example:

                                    Hole depth = 85.0 feet

                                    Ideal powder to hole depth ratio = 85.0/3.0 = 28.33333 feet

                                    Ideal number of sticks = 28.33333/2.0 = 14.166666

                                    Ideal powder charge = 14.166666*5.0 = 70.833333 pounds

                                    Actual number of sticks = 14 ß Notice that this is an integer value.

                                    Actual charge = 14*5 = 70 pounds ß Notice that this is an integer computation.

                                   

An input data file called oil_explore contains exploration information for each well site. The first record line of the input file defines the number of sites to be read into the program (the control number). Each succeeding record line has two columns, where the first column is the well site number and the second column is the hole depth of the well in feet. The two numbers are separated by a comma as the line delimiter.

ASSIGNMENT:

Write a C program that will read the required values from the input file, compute the hole to depth ration, the ideal number of sticks, the ideal powder charge, the actual powder charge, and the actual number of sticks. Except for the main headings, use a single for loop to control the reading, computing, and printing operations. Your program will produce a report in tabular format. Page 2 shows the layout format style. Print the table to the computer screen and to an output file called oil_report.

Once the program is working, modify the program to account for any hole depth that is less than 30 feet. If the hole depth is less than 30 feet print the well site number, the well depth, and a message that the hole is too shallow for blasting, else print the well site number, the well depth, the ideal charge, the actual change, and the number of sticks.

When verifying if the input exists, use the following print statement to display a message to the computer screen only.

printf(" ERROR READING INPUT FILE PROGRAM TERMINATED ");

OUTPUT FORMAT:

****************************************************

               DAILY DRILLING REPORT              

SITE   DEPTH   IDEAL POWDER   ACTUAL POWDER   STICKS

ID    (ft)      (lbs)           (lbs)

xxxx     xxx     xxx.xx            xx          xxx

  .      .         .               .           .

  .       .          .               .           .

xxxx    xxx   HOLE TOO SHALLOW FOR BLASTING

.       .          .               .           .

xxxx    xxx      xxx.xx            xx          xxx

****************************************************

FILE PATHS:

Before submitting your source program to Blackboard make sure that you set your file paths in your program as follows:

#define ????? “u:\engr 200\oil_explore.txt

#define ????? “u:\engr 200\oil_report.txt

The question marks will be the variables that you choose to use as your input and output pointer variables. If the file paths are not correctly set when you submit your program, it will be rejected and you will be required to change the paths to the correct settings and resubmit.

Explanation / Answer

#include<stdio.h>


int main(){

    FILE *fp;
    int site_no;
    double hole_depth;
    double hole;
    double depth;
    double ideal_powder;
    double ideal_sticks;
    int actual_sticks;
    int actual_charge;

    fp = fopen("well.txt","r");
    if (fp == NULL){
       printf(" ERROR READING INPUT FILE PROGRAM TERMINATED ");
       return 0;
    }
  

    printf("************************************************************** ");
    printf("           DAILY DRILLING REPORT                              ");

    printf("%-15s%-15s%-15s%-15s%-15s ","SITE ID","DEPTH","IDEAL POWDER","ACTUAL POWDER", "STICKS");
    printf("%-15s%-15s%-15s%-15s%-15s ","","(ft)","(lbs)","", "");


    while(!feof(fp)){
         fscanf(fp,"%d %lf", &site_no, &hole);
         if (hole > 30) {
            hole_depth = hole/3.0;
            ideal_sticks = hole_depth/2.0;
            ideal_powder = ideal_sticks * 5.0;
            actual_sticks = (int)ideal_sticks;
            actual_charge = actual_sticks * 5;
            printf("%-15d%-15.3lf%-15.3lf%-15d%-15d ",site_no,hole,ideal_powder,actual_charge, actual_sticks);
         }
         else {
              printf("%-15d%-15lf%-15s ",site_no,hole,"hole is too shallow for blasting" );
         }
        
        
    }
    fclose(fp);
    return 0;


}