這是一個計算5個商店銷售額的計劃, ,我應該創建一個程序來顯示它今天的每個收入。 這是我到目前爲止有:銷售條形圖
#include <iostream>
using namespace std;
int main()
{
//stores 1-5 variables
int store1; int store2; int store3; int store4; int store5;
// calculations
int sale1; int sale2; int sale3; int sale4; int sale5;
int counter;
cout << "Please enter today's sales for store 1: " ;
cin >> store1;
cout << "Please enter today's sales for store 2: " ;
cin >> store2;
cout << "Please enter today's sales for store 3: " ;
cin >> store3;
cout << "Please enter today's sales for store 4: " ;
cin >> store4;
cout << "Please enter today's sales for store 5: " ;
cin >> store5;
cout << endl << "Sales Bar Chart";
cout << endl << "Each asterisks (*) respresents $100" << endl;
sale1 = sale1/100;
sale2 = sale2/100;
sale3 = sale3/100;
sale4 = sale4/100;
sale5 = sale5/100;
cout << "Store 1: ";
for (counter = 0; counter < sale1; counter++)
cout << '*';
cout << endl << "Store 2: ";
for (counter = 0; counter < sale2; counter++)
cout << '*';
cout << endl << "Store 3: ";
for (counter = 0; counter < sale3; counter++)
cout << '*';
cout << endl << "Store 4: ";
for (counter = 0; counter < sale4; counter++)
cout << '*';
cout << endl << "Store 5: ";
for (counter = 0; counter < sale5; counter++)
cout << '*';
cin.get();
cin.get();
我的問題是,程序是假設輸出銷售這樣
Enter today's sales for store 1 : 100
Enter today's sales for store 2 : 200
Enter today's sales for store 3 : 300
Enter today's sales for store 4 : 400
Enter today's sales for store 5 : 500
銷售條形圖 每個*代表$ 100 存儲1:* 店2:* 店3:* 商店4:* 商店5:*
然而,我的投入只是把numerou這個星號的數量是這樣的 http://tinypic.com/view.php?pic=9h0wh2&s=8#.VHJjb4vF-QM 我不知道我做錯了什麼。
*「我不知道我做了什麼」*不是一個很好研究的編程問題。 – 2014-11-23 22:50:10
您是否正在閱讀編譯此代碼時得到的編譯器警告?你可能禁用了編譯器警告?您可以自動獲得類似您的拼寫錯誤的幫助。 – 2014-11-23 22:56:39
好點。下次我會記住這一點,謝謝。 – 2014-11-23 23:08:35