Question: Math oriented C++ question: I am writing a program to calculate real numbers from continued fraction expansions. I have a text file named problem1data.txt will

Math oriented C++ question:

I am writing a program to calculate real numbers from continued fraction expansions. I have a text file named problem1data.txt will contain the expansions, with one per line, which consist of an integer, followed by a semicolon, followed by additional integers, separated by commas. It looks like: 3;7,15,1,292,1,1,1,2,1,3 1;2,2,2,2,2,2 2;1,2,1,1,4,1,1,6,1,1,8 The program should process this file, compute the continued fraction expansions of each line, and write them to an output file named problem 1 output.txt with 16 digits of precision. I started working on calling the data and have attached that code, please correct if there are mistakes. I need help calculating the real numbers now from the continued fractions. I don't know how to use the called up data to do this. Someone suggest storing the integers in a vector and then immediately calculating by starting at the back of the first fraction and iterating back through the numbers (using the reciprocal and the previous number at every iteration) and writing the result to a file.

#include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  using namespace std; int main(){ ifstream input_file("problem1data.txt"); if(!input_file.is_open()){ cout << "The file did not open!" << endl; // this was in an example code but idk return 0; } if(input.is_open()){ while(!input.eof()){ string first_one; getline(input, first_one';'); // reading the number int first_number = stoi(first_one); // i think this is converting to integer while(getline(idk, next, ',')){ int next_number = stoi(next); integers.push_back(next_number); } } } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!