Write your question here.
I'm having trouble producing this output. His solution is only 60 lines of code and he challenged us to complete it in fewer lines for extra points suffice to say we do not skimp on sufficient comment. CS111, basically an intro to programming. I've got some code down, but I want to produce the code and am not sure how to approach it in terms of saving lines. If someone could perhaps nudge me without giving source code, other than say, an if loop would do, or, if functions could help there. The output should look like this
Welcome to the Babbage Log Engine
Lines Per Page: 5
Pages: 3
0.1 2.0
----------------------------------------------------------------------
0.1 -2.3026 0.6 -0.5108 1.1 0.0953 1.6 0.4700
0.2 -1.6094 0.7 -0.3567 1.2 0.1823 1.7 0.5306
0.3 -1.2040 0.8 -0.2231 1.3 0.2624 1.8 0.5878
0.4 -0.9163 0.9 -0.1054 1.4 0.3365 1.9 0.6419
0.5 -0.6931 1.0 0.0000 1.5 0.4055 2.0 0.6931
----------------------------------------------------------------------
2.1 4.0
----------------------------------------------------------------------
2.1 0.7419 2.6 0.9555 3.1 1.1314 3.6 1.2809
2.2 0.7885 2.7 0.9933 3.2 1.1632 3.7 1.3083
2.3 0.8329 2.8 1.0296 3.3 1.1939 3.8 1.3350
2.4 0.8755 2.9 1.0647 3.4 1.2238 3.9 1.3610
2.5 0.9163 3.0 1.0986 3.5 1.2528 4.0 1.3863
----------------------------------------------------------------------
4.1 6.0
----------------------------------------------------------------------
4.1 1.4110 4.6 1.5261 5.1 1.6292 5.6 1.7228
4.2 1.4351 4.7 1.5476 5.2 1.6487 5.7 1.7405
4.3 1.4586 4.8 1.5686 5.3 1.6677 5.8 1.7579
4.4 1.4816 4.9 1.5892 5.4 1.6864 5.9 1.7750
4.5 1.5041 5.0 1.6094 5.5 1.7047 6.0 1.7918
----------------------------------------------------------------------
For the specific assignment, check this link out
https://cs.maryvillecollege.edu/wiki/Intro_CS_I/fall2019/prog3
I have recently rekindled my love for computers for this class and recently had to drop my CS minor but I really need insight.
Thanks so much!
I am unsure if this is the right approach. The full source code is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
/*col is number of columns, row is number of rows, pages is num of pages lines is num of lines */
int n, col, row, pages, lines;
double value, x, entries, lentry; //value of log(x), x for use of log(x)
//Display welcome message
cout << "Welcome to the Babbage Log Engine" << endl
<< endl << endl;
//get lines and page numbers
cout << "Lines Per Page: " << endl;
cin >> lines;
cout << "Pages: " << endl;
cin >> pages;
//number of columns and rows
col = 4;
x = 0.1;
//calculate n
n = lines * col;
//calculate entries
entries = log(x);
//display results of user input
do
{
cout << entries << setw(70) << lentry << endl;
cout << setw(70) << setfill('-') << entries << endl;
//calculate entries
entries = log(x)
//increase log to be computed
x++;
} while(entries <= lines);
}
|