#include using namespace std; int main() { const double COST_PER_PAGE = 0.02; const double BASE_COST = 0.50; int volumes = 1; int pages = 0; int ppv = 0; double cost = 0; cout << "Number of pages in the book: "; cin >> pages; if (pages <= 0) { cerr << "Books have pages...exiting."; return 0; } // Calculate the base cost... without binding cost = BASE_COST + (COST_PER_PAGE * pages); ppv = pages; if (pages > 800) { volumes = 1; // Split into more and more volumes until pages are <= 800 while (ppv > 800) { volumes++; ppv = pages / volumes; } } // We check the pages per VOLUME and then multiply the cost times the number of volumes, makes sense eh? if (ppv > 550) cost += 1.75 * volumes; else if (ppv > 300) cost += 1.00 * volumes; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "The cost of the book will be: $" << cost << endl; cout << "Volumes: " << volumes << endl; cout << "Page per Volume: " << ppv << endl; system("pause"); return 0; }