/* Sales - User enters number of items sold.

This program calculates and displays, in a bar chart, how much money was earned. @author Bradley Sobie @version May 17, 2010 CIS 2252 */ #include "stdafx.h" #include <iostream> #include <iomanip> using std::cout; using std::cin; using std::endl; using namespace std; int main() { int numL=0; int numC=0; double earnL; double earnC; cout << "Welcome to the Lemonade Stand Program\n- Lemonade: $0.50 per cu p.\n- Cookies: $1.00 per cookie.\n\n"; cout << "Enter the number of cups of lemonade sold: "; cin >> numL; if(numL<0) { while(numL<0) { cout << "\n- enter a value greater than or equal to zero : "; cin >> numL; } } cout << "\nEnter the number of cookies sold: "; cin >> numC; if(numC<0) { while(numC<0) { cout << "\n- Enter a value greater than or equal to zero : "; cin >> numC; } } cout << "\nNumber Sold\n===========\n"; cout << "Lemonade: " << numL << endl; cout << "Cookies: " << numC << endl; cout << "\nLemonade: "; for(int i=1; i<=numL; i++)

{ if(i%10==0) cout << " "; else cout << "*"; } cout << "\nCookies: "; for(int i=1; i<=numC; i++) { if(i%10==0) cout << " "; else cout << "*"; } earnL = numL*.5; earnC = numC; cout << "\n\nDollars Earned\n==============\n"; cout << "Lemonade: $" << fixed << setprecision(2) << earnL << endl; cout << "Cookies: $" << fixed << setprecision(2) << earnC << endl; cout << "\nLemonade: "; for(int i=1; i<=earnL; i++) { if(i%10==0) cout << " "; else cout << "$"; } cout << "\nCookies: "; for(int i=1; i<=earnC; i++) { if(i%10==0) cout << " "; else cout << "$"; } char ch; cin >> ch; return 0; }