I am wanting to add the date to this program, how do I do it? What I mean is everytime I get into to it I want to be able to enter the days date, help please...Thanks
Code:
// Gail Sears
/*This program allows the user to add trucks to their
inventory. It also allows them to add and remove donations
from the truck chosen. It also display a chart of
what trucks are in inventory, with the name of the
truck and the amount of donations in each one.
*/
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#define max_trucks 500
#define max_cap 250
class OIL_TANK
{
private:
int ID_NUM;
int TRUCK_CAP;
int DON_ON_HAND;
static int NUM_TRUCKS;
public:
OIL_TANK (int id, int don= 0);
~ OIL_TANK ();
int ADD_DONATIONS (int amt);
int REMOVE_DONATIONS (int amt);
inline int GET_ID_NUM (){return ID_NUM;}
inline int GET_TRUCK_NAME () (return MERS/GOODWILL;)
inline int GET_CAP () {return TRUCK_CAP;}
inline int GET_CONT() {return DON_ON_HAND;}
static int TOTAL_TRUCKS ();
};
int OIL_TANK::NUM_TRUCKS = 0;
OIL_TANK::OIL_TANK (int id, int don)
{
ID_NUM = id;
DON_ON_HAND = don;
TRUCK_CAP = 250;
++NUM_TRUCKS;
}
int OIL_TANK::ADD_DONATIONS (int amt)
{
if (DON_ON_HAND + amt > TRUCK_CAP)
return -1;
else
return DON_ON_HAND += amt;
}
int OIL_TANK::REMOVE_DONATIONS (int amt)
{
if (DON_ON_HAND - amt < 0)
return -1;
else
return DON_ON_HAND -= amt;
}
OIL_TANK::~OIL_TANK ()
{
delete [] TRUCK_NAME;
}
int OIL_TANK::TOTAL_TRUCKS()
{
return NUM_TRUCKS;
}
OIL_TANK* create_truck();
void display (OIL_TANK&);
void main ()
{
int don_amt,
result,
count = 0,
choice;
char select = ' ';
char answer = ' ';
OIL_TANK* truck_table[max_trucks];
do
{
cout << "\n\n WELCOME TO THE MERS/GOODWILL TRUCK INVENTORY\n";
cout << "\n\nPlease choose a number from the menu below.\n";
cout << "\nl. Add a truck to inventory.";
cout << "\n2. Add donations to a truck.";
cout << "\n3. Remove donations from a truck.";
cout << "\n4. Display the trucks in inventory.";
cout << "\n5. Quit the Program.";
cout << "\n\nPlease enter your selection now: ";
cin >> select;
clrscr ();
switch (select)
{
case '1':
cout << "\nDo you want to add a truck to inventory? (Y/N): ";
cin >> answer;
while (toupper(answer) == 'Y' && count < max_trucks)
{
truck_table [count] = create_truck();
++count;
cout << "\nDo you want to add a truck to inventory? (Y/N): ";
cin >> answer;
}
break ;
case '2':
cout << "\nTo which truck would you like to add donations?(truck_num): ";
cin >> choice;
if (choice < 1 || choice > count)
{
cout << "\n\nINVALID ENTRY!!! ";
break;
}
else
{
cout << "n\nPlease enter the amount of donations to add: ";
cin >> don_amt;
result = truck_table[choice - 1]->ADD_DONATIONS (don_amt);
if (result < 0)
cout<< "\nERROR Truck capacity is not large enough!!!\n";
else
cout << "\nDonations Added!!! ";
break;
}
case '3':
cout << "\nFrom which truck would you like to remove donations? (truck_num): ";
cin >> choice;
if (choice < 1 || choice > count)
{
cout << "\n\nINVALID ENTRY!!! ";
break;
}
else
cout << "\nPlease enter the amount of donations to remove: ";
cin >> don_amt;
result = truck_table[choice - 1]->REMOVE_DONATIONS (don_amt);
if (result < 0)
cout <<"\nERROR Truck does not have enough donations in it!!!\n";
else
cout << "\nDonations Removed!!! ";
break;
case '4':
for (int x = 0; x < count; ++x)
display(*truck_table[x]);
break;
}
}
while (select != '5');
cout << "\n\n\n\n THANK YOU";
cout << "\n\n GOODBYE";
for (int x = 0; x < count; ++x)
delete truck_table[x];
}
OIL_TANK* create_truck()
{
int id_num,
donations = 0;
char name [80];
OIL_TANK* tankptr;
cout << "\nPlease enter the truck number: ";
cin >> id_num;
cin.ignore(81, '\n');
cout << "\nPlease enter the truck name: ";
cin.getline(name, 80);
cout << "\nPlease enter the amount of donations in truck: ";
cin >> donations;
cin.ignore(81, '\n');
clrscr();
tankptr = new OIL_TANK (id_num, donations);
cout << "\n\n\Trucks in inventory: " << tankptr->TOTAL_TRUCKS();
return tankptr;
}
void display (OIL_TANK& tank)
{
cout << "\nTruck ID " << tank.GET_ID_NUM();
cout << "\nName of Truck: " << tank.GET_NAME();
cout << "\nTruck Capacity: " << tank.GET_CAP();
cout << "\nDonations on Hand: " << tank.GET_CONT();
}
Comment