Question
I HAVE UPLOADED FILES TO AS WHAT THE CODE DOES...THANK YOU! This is the code but I want to add the stream reader so the
I HAVE UPLOADED FILES TO AS WHAT THE CODE DOES...THANK YOU!
This is the code but I want to add the stream reader so the input is taken from a text file and prints the output. HELP!
NOTE; THE SOLUTIONS ALREADY AVAILABLE ON CHEQQ DONT WORK..PLEASE RE-DO THIS PROBLEM AND GIVE SOME EXPLAINATION TO YOUR CODE SO IT HELPS ME TO UNDERSTAND...THANK YOU!
using System; using System.IO;
namespace Group1_Drill_Assignment { class Program { static void Main(string[] args) {
bool[,] wellpoints = new bool[400, 200]; points(wellpoints); Console.WriteLine("Enter the first letter of the direction you want to drill in (u,d,l,r) and a positive legnth by which you want to drill (Enter q to quit) "); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("NOTE: Make sure to put a space between the direction and the length "); Console.ForegroundColor = ConsoleColor.White;
int[] currentIndex = { 199, 4 }; int[] nextIndex = { currentIndex[0], currentIndex[1] }; string[] p = Console.ReadLine().Split(); char direction = char.Parse(p[0]);
while (direction != 'q') { int value = Int32.Parse(p[1]); getIndex(direction, value, currentIndex); bool safe = approveValues(currentIndex, nextIndex, wellpoints); string message = (safe) ? "safe" : "DANGER";
Console.WriteLine("{0} {1} {2}", currentIndex[0] - 200, (currentIndex[1] + 1) * -1, message); nextIndex[0] = currentIndex[0]; nextIndex[1] = currentIndex[1]; if (!safe) break; p = Console.ReadLine().Split(); direction = char.Parse(p[0]);
} }
public static void points(bool[,] wellpoints) { wellpoints[200, 0] = true; wellpoints[200, 2] = true; wellpoints[200, 1] = true; wellpoints[201, 2] = true; wellpoints[202, 2] = true; wellpoints[203, 2] = true; wellpoints[205, 2] = true; wellpoints[206, 2] = true; wellpoints[207, 2] = true; wellpoints[203, 3] = true; wellpoints[205, 3] = true; wellpoints[203, 4] = true; wellpoints[204, 4] = true; wellpoints[205, 4] = true; wellpoints[207, 3] = true; wellpoints[207, 4] = true; wellpoints[207, 5] = true; wellpoints[207, 6] = true; wellpoints[206, 6] = true; wellpoints[205, 6] = true; wellpoints[204, 6] = true; wellpoints[203, 6] = true; wellpoints[202, 6] = true; wellpoints[201, 6] = true; wellpoints[200, 6] = true; wellpoints[199, 6] = true; wellpoints[199, 5] = true; wellpoints[199, 4] = true; }
public static void getIndex(char d, int value, int[] currentIndex) { if (d=='u') { currentIndex[1] = currentIndex[1] - value; } else if (d == 'l') { currentIndex[0] = currentIndex[0] - value; } else if (d == 'd') { currentIndex[1] = currentIndex[1] + value; } else if (d == 'r') { currentIndex[0] = currentIndex[0] + value; } }
public static bool approveValues(int[] currentIndex, int[] nextIndex, bool[,] wellpoints) { bool value = true; int count = 0; for(int i = nextIndex[0]; i 1) { value = false; } count += 1; } } return value;
} } }
Problem J4: Boring Business Problem Description Boring is a type of drilling, specifically, the drilling of a tunnel, well, or hole in the earth. With some recent events, such as the Deepwater Horizon oil spill and the rescue of Chilean miners, the public became aware of the sophistication of the current boring technology. Using the technique known as geosteering, drill operators can drill wells vertically, horizontally, or even on a slant angle. A well plan is prepared before drilling, which specifies a sequence of lines, representing a geomet- rical shape of the future well. However, as new information becomes available during drilling, the model can be updated and the well plan modified. Your task is to write a program that verifies validity of a well plan by verifying that the borehole will not intersect itself. A two-dimensional well plan is used to represent a vertical cross-section of the borehole, and this well plan includes some drilling that has occurred starting at (0, -1) and moving to (-1,-5). You will encode in your program the current well plan shown in the figure below: -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 -1 -2 -3 -4 S -5 -6 -7 -8 Input Specification The input consists of a sequence of drilling command pairs. A drilling command pair begins with one of four direction indicators (d for down, u for up, 1 for left, and r for right) followed by a positive length. There is an additional drilling command indicated by q (quit) followed by any integer, which indicates the program should stop execution. You can assume that the input is such that the drill point will not: rise above the ground, nor be more than 200 units below ground, nor 8 be more than 200 units to the left of the original starting point, nor be more than 200 units to the right of the original starting point Output Specification The program should continue to monitor drilling assuming that the well shown in the figure has already been made. As we can see (-1,-5) is the starting position for your program. After each command, the program must output one line with the coordinates of the new position of the drill, and one of the two comments safe, if there has been no intersection with a previous position or DANGER if there has been an intersection with a previous borehole location. After detecting and reporting a self-intersection, your program must stop. Sample Input 1 1 2 d 2 r 1 qo Output for Sample Input 1 -3 -5 safe -3 -7 safe -2 -7 safe Sample Input 2 r 2 d 10 r 4 Output for Sample Input 2 1 -5 safe 1 -15 DANGERStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started