Question
HE Please can you help with this program in C++. Here is my code, I need the commented part to be fixed which is supposed
HE
Please can you help with this program in C++. Here is my code, I need the commented part to be fixed which is supposed to produce the output for line 1. I have successfully done the code for the output for line 2.
#include
using namespace std;
int main() { ifstream inData; inData.open("input.txt"); ofstream outData; outData.open("output.txt");
if (!inData) { cout
double x1; double y1; double x2; double y2; double d1; double d2;
/*
inData >> x1 >> y1;
while (inData>>x2>>y2) { d1 = 0; d1 = d1 + sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); outData
inData >> x1 >> y1;
while (!inData.eof()) { inData >> x2 >> y2; } cout
return 0; }
The linear distance, d, between two points, (x1,yi) and (x2, y2), on a two dimensional plane, is given by: (12-11 )2 + (3/2-yl)2 You are required to write a computer programme in C++ that reads in a list of r-y coordinates from a text file and determines the total linear distance between all points and the linear distance between the first and last point Your programme must comply with the following specifications and requirements (refer to the examples below for more clarity): A file named input.txt will contain the r-y coordinates. Each line of the file will . You may assume that all numbers in input.txt are correctly formed and that there . Your programme must generate a file called output.txt. The first line of this file contain an r and y value. The total number of lines is unspecified is no invalid data (such as text). must contain the total linear distance between all points. The second line must contain the linear distance between the first and last point. produce any console output. than sqrt to perform the calculations . Your program must run without any console input from the user and must not . Note: you may not make use of any standard library or third party routines other
Step 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