Group Assignment
Group Assignment
Group Assignment
p
Program: -degree
No Name ID
01 Dagim baji 0064/10
02 Yohannis Yadasa 0058/10
03 Estifanos Alebachew 0062/10
04 Beyene Dangiha 0008/10
05 Gemeda Yemane 0024/10
06 Selamawet Alemayehu 0047/10
07 Derara Tilahun 0038/10
08 Feyera Leta 0020/10
09 Elsabet Abebe 0017/10
10 Kinde Addis
11 Tadele Fikadu 0051/10
12 Buzuneshi Bekele
// function prototypes
void addData(InventoryRecord list[], int& size);
void dispData(const InventoryRecord list[], int size);
void remData( const InventoryRecord list[], int size);
void saveFile(const InventoryRecord list[], int size);
void openFile(InventoryRecord list[], int& size);
char getMenuResponse();
int main(int argc, char *argv[])
{
InventoryRecord recList[MAX_SIZE];
int numOfRecs = 0;
bool run = true;
do
{
cout << "Hero's Inventory - " << numOfRecs << " items in your bag" << endl;
switch ( getMenuResponse() )
{
case 'A': addData(recList, numOfRecs); break;
case 'D': dispData(recList, numOfRecs); break;
case 'R': remData(recList, numOfRecs); break;
case 'O': openFile(recList, numOfRecs); break;
case 'S': saveFile(recList, numOfRecs); break;
case 'Q': run = false; break;
default : cout << "That is NOT a valid choice" << endl;
}
} while (run);
cout << endl << "Program Terminated" << endl;
return EXIT_SUCCESS;
}
system("PAUSE");
system("cls");
}
if(size < 1) {
cout << "Nothing to display" << endl;
} else {
cout << "All Items in your Bag" << endl << endl;
cout << fixed << setprecision(2);
cout << "Item Name Qty Value" << endl;// It is not displaying right the alignment is
off
cout << "~~~~~~~~~~~~~~~~~~" << endl;
cout <<"Item Name:
cout << left;
for (int i = 0; i < size; i++) {
cout << setw(21) << list[i].name << right
<< setw(4) << list[i].qty
<< setw(10) << list[i].value << left << endl;
cost = cost + list[i].value * list[i].qty;
}
system("cls");
cout << "Reading inventory from the disc ";
system("PAUSE");
system("cls");
}
else {
// something went wrong with opening the file
cout << "ERROR: problem with file" << endl;
system("PAUSE");
system("cls");
}
char getMenuResponse()
// Task: Put the menu on screen and get a response
{
char response;
cout << endl << "Make your selection" << endl
<< "(A)dd Items, (D)isplay Items, (R)emove items, (O)pen File, (S)ave File, (Q)uit" <<
endl
<< "> ";
cin >> response;
cin.ignore(256, '\n');
// clean-up up to 256 chars including the delimiter specified (\n, the endl)
return toupper(response);
}
//end