Originally Posted by
Crash
Loser code ?
kk.
You can
if you want.
teh omgz i r god kk i tech him somtin useful
fstereeme is foar riting to teh files :
Code:
#include <fstream>
using namespace std;
...
fstream file("C://fag.txt", ios::out);
file << "I r guna use teh return 0";
file.close();
return 0;
...
lolz. You're a dork. :P
I already know how to write to a file.
I am ON that section right now in my book. ;-)
So, like this:
[php]// Credits:
// D-Vid aka Illusionz
// flashlight95 -- For the idea of using the if
// crash -- Freeing memory usage
#include <iostream>
int main()
{
using namespace std;
float CppPrimer;
int pages;
cout << "Enter the total amount of pages that you've read so far: \n\n";
cin >> pages;
cout << endl;
CppPrimer = 1225;
if (pages>2501)
{
cout << "You input the incorrect value, it has to be less than 2501 pages." << endl;
system("PAUSE");
cout << endl;
}
else if (pages<2501)
{
cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl;
cout << "Percentage TOTAL outta all the books: " << pages / 2501 * 100 << "%" << endl;
system("PAUSE");
cout << endl;
}
else
{
cout << "You're DONE learning from those books!" << endl;
system("PAUSE");
cout << endl;
}
return 0;
}[/php]
What sucks is, by putting that if else statement in there, it gave me a problem:
[IMG]https://i33.photobucke*****m/albums/d55/y_owns_you/problem.png[/IMG]
EDIT:
I fixed my problem, and it was YOUR fault, crash! Damnit. lolz.
Here's the NEW code I fixed:
Code:
// Credits:
// D-Vid aka Illusionz
// flashlight95 -- For the idea of using the if
// crash -- Freeing memory usage
#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;
}
But now the NEW problem I am running into is that with that if statement, when I get done with the FIRST book, and say I have read all but one page. Total = 2501 last page = 2500
I wanna make it where the line:
Code:
cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl;
doesn't come up with a value OVER 100%.
How would I do that?