問題: 創建一個程序,首先要求用戶輸入他/她今天吃過的物品數量,然後輸入每個物品的卡路里數。然後計算他/她在當天進食的卡路里數並顯示該值。卡路里計數循環
#include <iostream>
using namespace std;
int main()
{
int numberOfItems;
int count; // loop counter for the loop
int caloriesForItem;
int totalCalories;
cout << "How many items did you eat today? ";
cin >> numberOfItems;
cout << "Enter the number of calories in each of the " << numberOfItems << " items eaten:" >> endl;
while (caloriesForItem)
{
cout << "Please enter item calories:";
cin >>caloriesForItem;
count == numberOfItems;
}
cout << "Total calories eaten today = " << totalCalories;
return 0;
}
最後,我不知道如何讓它讀取和計算,因爲它說它必須是一個while循環。