#include
using namespace std;
int main()
{
const int NUM = 5;
double prices[] = { 9.92, 6.32, 12.63, 5.95, 10.29 };
double units[5];
double amounts[5];
double total = 0;
for (int i = 0; i < NUM; i++){
cout << "Enter number of units" << endl;
cin >> units[i];
amounts[i] = prices[i] * units[i];
total = total + amounts[i];
}
cout << "Price Units Amount" << endl;
for (int i = 0; i < NUM; i++){
cout << prices[i] <<setw(15)<< units[i] <<setw(15) << amounts[i] << endl;
}
cout << "Total:" << total << endl;
system("PAUSE");
return 0;
}
代码没发现问题,头文件:
#include <iostream>
#include <iomanip>