I'm supposed to make a code that will "contain three arrays. One that contains 10 integer part numbers, one that contains 10 floating-point prices, and one that contains 10 string descriptions corresponding to the part number and price. The arrays can be filled via a loop prompt cycle, or hard-coded constants, or from a disk file (I chose loop prompt cycle) - student choice on the load mechanism. Display the arrays on column format like the following:
Part #---------Description--------------Price
12435---------Pokemon Card Pack----$432.21
35424---------1000-PK Slim JIM------$1234.55
90345---------Supreme Hoodie BLK--$233.90
29458---------Taco Seasoning--------$34.99
but with spaces instead of -
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iomanip>
#include <iostream>
#include "cstdlib"
using namespace std;
int main ()
{
int part_num [10];
string desc [10];
float price [10];
int PartCount;
do
{
cout << "Number of Items (10 max): ";
cin >> PartCount;
}
while ((PartCount > 10) || (PartCount < 1));
for (int i = 0; i < PartCount; i++)
{cout << endl << endl << "Ïtem " << i+1 << "of " << PartCount << endl << endl;
cout << "Enter Part Number: ";
cin >> part_num [i];
cout << "Enter Item Name: ";
cin >> desc [i];
cout << "Enter Price: ";
cin >> price [i];
}
cout << endl << endl << endl;
cout << setw(15) << "Part #" << setw(35) << "Item Name" << setw(18) << "Price" << endl;
for (int i = 0; i < PartCount; i++)
{
cout << setw(15) << part_num [i] << setw(35) << desc [i] << setw(15) << "$" << price [i] << endl;
}
return 0;
}
|
Every time I run it, It just stops after getting the number of items. Can Someone please help me?