Okay guys,
I have this code I have been messing around with a little bit that I wrote on my own, as a way to take what I am currently learning from the book I am reading, and put it into something more than just retyping source codes that're in the book. I want to try many different methods that'll produce practically the same outcome for this simple program.
The whole point here with this program is for me to enter the amount of pages I have read, and have it automatically calculate the percentages for me to update my sig with, of my C++ Learning Status.
What I am having a problem with here is I have it set up where it outputs the percentage I am on the CURRENT book I am reading, and the total percentage outta the 2(soon will be MORE) books I have on C++. The problem is that when I am done with the first book(1225 pages long) and I start on my other book, that means I will have read for example 1230 pages(5 pages of the next book and ALL 1225 of the first), it doesn't make the FIRST book stop at 100% it makes the percentage of the first book show as 100.41%. I need some advice on how to get this to stop at 100% but for it to STILL count up the total percentage.
Here's my code::
[php]
// Credits:
// D-Vid aka Illusionz -- DBag4Life on MPGH
// flashlight95 -- For the idea of using the if
// crash #include <iostream>
int main()
{
using namespace std;
float CppPrimer = 1225;
float total = 2501;
int pages;
cout << "Enter the total amount of pages that you've read so far: \n\n";
cin >> pages;
cout << endl;
if (pages>total)
{
cout << "You input the incorrect value, it has to be less than 2501 pages." << endl;
system("PAUSE");
cout << endl;
}
else if (pages<total)
{
cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl;
cout << "Percentage TOTAL outta all the books: " << pages / total * 100 << "%" << endl;
system("PAUSE");
cout << endl;
}
else
{
cout << "You're DONE learning from those books!" << endl;
system("PAUSE");
cout << endl;
}
return 0;
}
[/php]
I would like to hear some constructive criticism, but I don't want any flaming. I AM new at C++, and I am trying to learn different styles of coding.