Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

What are the reasons for the recent emergence of visual analytics?

Answered: 1 week ago

Question

=+4 Are national cultures converging or diverging?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago