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

Need help with c++ program. Write a program that stores stock symbols into dynam

ID: 3802601 • Letter: N

Question

Need help with c++ program.

Write a program that stores stock symbols into dynamic arrays. The user will enter as many stocks as he/she wishes. The program should display the list of stocks after each one is entered. Sort stocks in alphabetical order. After that, use the program as a starting point for a menu-based program. The menu-based program should include these options:

1. Add a new stock.

Include room for the stock symbol, the name of the stock, and the current price.

2. Edit a stock.

Provide the ability to locate a stock based on its respective symbol and change the current price.

3. Delete a stock.

Offer the user the opportunity to enter a stock symbol and, if found, to delete the stock. If the particular stock symbol is not found, simply display an informative message to the user.

4. Display all stocks.

Display a list of all the current stocks stored in the array.

Explanation / Answer

#include<iostream>
using namespace std;
int input()
{
int i,n;
cout<<"Enter no. of stocks symbols wanna enter.";
cin>>n;
char stock[n];
for(i=0;i<n;i++)
{
cin>>stock[i];
for(j=0;j<=i;j++)
{
cout<<stock[j];
}
}
sort(stock,n);
}
int sort(char counter[], int j)
{
for ( int h = 0 ; h<j ; h++ )
{
for(int l=0; l<j; l++)
{
if(counter[l+1]>counter[l])
{
temp = counter[l+1];
counter[l+1] = counter[l];
counter[l] = temp;
temp_1= uniq[l+1];
uniq[l+1] = uniq[l];
uniq[l] = temp_1;

}
}

}
menu();
}
int add();
int edit();
int delete();
int display();
int menu()
{
char ch;
cout<<" 1. Add a new stock.Include room for the stock symbol, the name of the stock, and the current price.";
cout<<"2. Edit a stock.Provide the ability to locate a stock based on its respective symbol and change the current price.";
cout<<"3. Delete a stock.Offer the user the opportunity to enter a stock symbol and, if found, to delete the stock. If the particular stock symbol is not found, simply display an informative message to the user.";
cout<<"4. Display all stocks.Display a list of all the current stocks stored in the array.";
cout<<"Enter your choice:";
cin>>ch;
switch(ch)
{
case 1:
add();
break;
case 2:
edit();
break;
case 3:
delete();
break;
case 4:
display();
default:
cout<<"Enter correct choice:"
}
}
int main()
{
char ch;
input();
}