The basic formula of my program works.
Now I'm just trying to get it to only accept positive input numbers.
And when it's over, I want it to ask the user if they want to do it again, and if
they put a Y then do it again, and if they put a N, then quit. This is what I have so far, and I have a few errors. Please help?
Code:#include <iostream> #include <iomanip> using namespace std; double retail (double, double); int main() { double cost; double markup; char answer = 'y'; while (answer = 'y')||(answer = 'Y') { cout << "What is the item's wholesale cost? "; cin >> cost; cout << endl; cout << "What is the markup percentage? "; cin >> markup; cout << endl; if (cost >= 0) && (markup >= 0) { cout << "The retail price of the item is $ " << retail (cost, markup) << fixed << setprecision(2) << endl; } else { cout << "Please re-enter values using positive numbers only." << endl; } } cout << "Do you want to try again? (y/n) "; cin >> answer; cout << endl; return (0); } double retail (double wholesaleCost, double markupPercentage) { return (wholesaleCost + (wholesaleCost * (markupPercentage/100))); }



LinkBack URL
About LinkBacks



