Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP ME!!!!! In C++ language.....develop a program that simulates the sto

ID: 3581966 • Letter: P

Question

PLEASE HELP ME!!!!!

In C++ language.....develop a program that simulates the stock trading of a customer. Suppose we have at most 30 stocks in the system. So you can use arrays (all with size 30) to store the name, ID, and current price of each stock (hint: declare three arrays for name, ID and price respectively, and index 0 in each array denotes the corresponding information of the first stock). You also need to define appropriate variables to store customer information such ascustomer name, amount of money on her account, total amount of assets (money on her account plus the value of all stocks), and the list of stocks he/she holds. Suppose the customer can hold at most 10 stocks. So you can use an array to store the list of stocks he/she holds (hint: think how to denote the end of the list).  We also suppose that the customer initially has 1 million on her account. You can add additional variables or arrays in the program if you feel necessary. The program offers a menu for the user to choose.

List price: list the name and current price of all stocks

Buy a stock: ask the customer the ID of stock and the amount of shares to buy. You need to check whether the money on the customer’s account is enough or not. If not, you need to prompt the maximal amount of shares the customer can buy based on her money and ask the customer to re-input the amount of shares to buy.

List current position: list the information of all stocks hold by the customer, which includes stock name, stock ID, current price, the price of the stock when the customer bought it, and current margin (profits or losses).

Sell a stock: ask the customer the ID of stock and amount of shares she wishes to sell. The amount of shares to sell cannot be larger than that hold by the customer. Add the amount of money earned to the customer’s account.

Change Stock Price: when this is selected, the price of each stock will change randomly with a percentage in the range of [-10%, 10%]. You can also design your own method of how the price of a stock will be changed to make the program more interesting.  

Calculate profit: return the total of profits or losses the customer has had

Save current position: save current position of the customer (the same information as in item c) to a txt file.

Query asset: output the amount of assets of the customer to the console.

Explanation / Answer

#include<iostream.h>

#include<conio.h>

class item

{

    private:

        char name[20];

        int code[20];

        float price[20];

        int z;

    public:

        void add_(void);

        void delete_(void);

        void sell_(void);

        void display_(void);

        void initial(void){z=0;}

};

     void item :: add_(void)

       {

    clrscr();

    cout<<" Enter the item category    : ";

    cin>>name[z];

    cout<<"Enter the item code        : ";

    cin>>code[z];

    cout<<"Enter the price of the item: ";

    cin>>price[z];

    z++;

       }

       void item :: delete_(void)

       {

     int i,j;

     clrscr();

     cout<<" Please enter the item code:";

     cin>>i;

     for(j=0;j<z;j++)

    {

      if(code[j]==i)

      {

        price[j]=0;

        cout<<" The item is deleted from the list.";

        getch();

        break;

      }

    }

       }

      void item :: sell_(void)

      {

    char a;

    int i,j;

    float total_price=0;

    clrscr();

    cout<<" Enter the item code:";

    cin>>i;

    for(j=0;j<z;j++)

    {

      if (code[j]==i)

      {

        if(price[j]==0)

        {

          cout<<" Sorry.There is no item left in this catefory.";

          cout<<" Do you want to buy another item? y "<<endl;

          cin>>a;

          if (a=='y')

          {

        cout<<" Enter the item code:";

        cin>>i;

        j=-1;

          }

          else if (a=='Y')

          {

        cout<<" Enter the item code:";

        cin>>i;

        j=-1;

          }

          else

          {

        if (total_price!=0)

        {

          cout<<" Your total price is: ";

          cout<<total_price<<" Taka."<<" Thank You.";

        }

        cout<<"Bye...bye...";

        break;

          }

        }

        else

        {

          cout<<"Item category is: "<<name[j];

          cout<<" Item price is   : "<<price[j]<<"tk."<<endl;

          total_price+=price[j];

          price[j]=0;

        cout<<" Do you want to buy another item:y ";

          cin>>a;

          if (a=='y')

          {

        cout<<" Enter the item code:";

        cin>>i;

        j=-1;

          }

          else if (a=='Y')

          {

        cout<<" Enter the item code:";

        cin>>i;

        j=-1;

          }

          else

          { clrscr();

        cout<<" Your total price is: ";

        cout<<total_price<<"Taka."<<" Thank You.";

        break;

          }

        }

      }

    }

    getch();

    }

    void item :: display_()

     {

       int i,j=1;

       clrscr();

       for(i=0;i<z;i++)

      {

        cout<<j<<".Item category is: "<<name[i];

        cout<<" Item code is    : "<<code[i];

        cout<<" Item price is   : "<<price[i]<<"tk."<<endl<<endl;

        j++;

       }

        getch();

      }

int main ()

   {

    int i;

    item shoping_mall;

    clrscr();

    shoping_mall.initial();

    while(1)

    {

      cout<<"    What do you want to do?"<<endl;

      cout<<" 1: Add a new item.";

      cout<<" 2: Delete an item.";

      cout<<" 3: Sale an item.";

      cout<<" 4: Display all items.";

      cout<<" 5: Exit"<<endl;

      cout<<" Choose a number:";

      cin>>i;

      switch(i)

      {

        case 1:

        {

          shoping_mall.add_();

          break;

        }

        case 2:

        {

          shoping_mall.delete_();

          break;

        }

        case 3:

        {

          shoping_mall.sell_();

          break;

        }

        case 4:

        {

          shoping_mall.display_();

          break;

        }

           case 5:

        {

          cout<<"Good Bye! Thank you.";

          break;

        }

      }

      if (i==5)

        break;

      clrscr();

    }

    getch();

    return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote