⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5_3.cpp

📁 用VC编写的股票交易系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	volume_available=stock_volume;
	strcpy(Stock::code_for_analysis,"");
}
void Stock::Interface()
{
start:
	system("cls");
	cout<<"\n\n\t\t******************** Stock Exchange System"<<endl;
	cout<<"\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
	cout<<"\t\t   View Stock Exchange Market......[m]"<<endl;
	cout<<"\t\t   Login for existing user.........[i]"<<endl;
	cout<<"\t\t   Register for new user...........[r]"<<endl;
	cout<<"\t\t   Market analysis.................[v]"<<endl;
	cout<<"\t\t   Quit this program...............[q]"<<endl;
	cout<<endl<<"\t\t   Enter your choice here:";
	cin>>choice;
if((choice!='m')&&(choice!='i')&&(choice!='r')&&(choice!='v')&&(choice!='a')&&(choice!='q'))
	{
		system("cls");
		goto start;
	}
	else
		Switch_choice();
}
void Stock::Switch_choice()
{
	Stock temp,s[MAX];
	Customer c1;
	char pass_word[10];
	switch(choice)
	{
	case 'm':{
			system("cls");
			cout<<"\n\n\t\t******************** Stock Exchange System"<<endl;
			cout<<"\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
			cout<<"  Company\t\tCode\tIssued Volume\tVolume Available"<<endl;
				cout<<"  ~~~~~~~\t\t~~~~\t~~~~~~~~~~~~~\t~~~~~~~~~~~~~~~~\t"<<endl;			
ifstream dataFile("Stock_File.dat");  //Subject to change
			dataFile.read((char*)(&s),sizeof(s));			
			for(int x=0;x<5;++x)
				{
					s[x].Stock_Exchange_Market();
				}
				getch();
				temp.Interface();
				break;
			 }
	case 'i':{
				system("cls");
				cout<<endl<<endl;
				cin.get();
				cout<<"******************** Stock Exchange System"<<endl;
				cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
				cout<<"Account password: ";
				cin>>pass_word;
				cin.get();
				c1.Log_in(pass_word,c1);
				temp.Interface();
				break;
			 }
	case 'r':{
				system("cls");
				cout<<"Open New Account"<<endl;
				cout<<"~~~~~~~~~~~~~~~~"<<endl;
				c1.Register(&c1);
				ofstream write_customer("customer.dat",ios::app);
				write_customer.write((char*)&c1,sizeof(c1));
				write_customer.close();
				temp.Interface();
				break;
			 }
	case 'v':{
			system("cls");
			cout<<"\n\n\t\t******************** Stock Exchange System"<<endl;
			cout<<"\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
			cout<<"  Company\t\tCode\tIssued Volume\tVolume Available"<<endl;
			cout<<"  ~~~~~~~\t\t~~~~\t~~~~~~~~~~~~~\t~~~~~~~~~~~~~~~~\t"<<endl;			temp.Market_Analysis();
			break;
			 }
	case 'q':{
		  system("cls");
cout<<"Thanks for using ******************** Stock Exchange System!"<<endl;
		  cout<<"See you again!"<<endl;
		  exit(0);
			 }
	}
}
void Stock::Input_For_New_Stock()
{
	system("cls");
	cin.get();
	cout<<"Enter new stock name(XX_XXX): ";
	cin.getline(stock_name,20);
	cout<<"Enter stock code (capital letter & less than 5 character): ";
	cin.getline(stock_code,6);
	cout<<"Enter issue volume : ";
	cin>>stock_volume;
	cin.get();
	volume_available=stock_volume;
	num_of_stock++;
}
void Stock::Stock_Exchange_Market()
{cout<<"  "<<stock_name<<"\t\t"<<stock_code<<"\t"<<stock_volume<<"\t\t"<<volume_available<<endl;
}
void Stock::Market_Analysis()
{
	Stock s[MAX];
	int i=0,flag=0;
	ifstream dataFile("Stock_File.dat");  //Subject to change
	dataFile.read((char*)(&s),sizeof(s));			
	for(i=0;i<MAX;++i)
	{
		s[i].Stock_Exchange_Market();
	}
	cout<<endl;
	cin.get();
	cout<<"Type in the share code to view market analysis: ";
	cin.getline(code_for_analysis,6);
	i=0;
	while((i<MAX)&&(!flag))
	{
		if(strcmp(s[i].stock_code,code_for_analysis)==0)
		{
			getch();
			flag=1;
			break;
		}
		else
			i++;
		if(i==MAX)
		{
			cout<<"No code found"<<endl;
			cout<<"Press any key to proceed... "<<endl;
			getch();
			s[i].Interface();
		}
	}
	system("cls");
	cout<<"\t\t\t     Market Analysis "<<endl;
	cout<<"\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
	cout<<"\t\t\t     ("<<s[i].stock_name<<") "<<endl<<endl;
	if(i==0)
	{
		if(s[i].volume_available<=3000)
		{
	cout<<"\t"<<s[i].stock_name<<" has a very good performance, as the company "<<endl;
	cout<<"\tjust signed another 4 years contract with IOC.  As Beijing just won "<<endl;
	cout<<"\tthe bid of 2008 Olympic Games, company is expected to widen its market "<<endl;
	cout<<"\tin this country.  This has attract shareholders to invest in the share. "<<endl;
		}
		else if((s[i].volume_available>3000) && (s[i].volume_available<=7000))
		{
cout<<"\t"<<s[i].stock_name<<" is reserving its streak in the moderate side due to the"<<endl<<	"\tstagnant sales. Regional market has been rather inactive and sales"<<endl<<
	"\thave risen less than expected. The market has also been quiet due to"<<endl<< 	"\tthe domination by banking sector rally."<<endl;
		}
		else
		{
cout<<"     "<<s[i].stock_name<<" this week in poor performance.  "<<s[i].stock_name;
cout<<" ended weaker after       McDonald's Corp. said its yearly earnings would miss Wall "; 
cout<<"Street estimates and  a forecast of future demand from Nike Inc. disappointed investors."<<endl;
cout<<"	 Stock index futures sold on several occasions this week, pressured by  concerns that the Federal Reserve could raise interest "; 
cout<<"rates as early as May.   Investors are worried that if the Fed is too quick to undo some of last year's  aggressive rate cuts, ";
cout<<"the central bank could choke off the strength of a"<<endl;
cout<<"rebound in corporate profits that has yet to surface."<<endl;
		}
	}
	else if (i==1)
	{
		if(s[i].volume_available < 3000)
		{
cout<<"\tMomentum has picked up for "<<s[i].stock_name<<" in the last couple of days."<<endl<<"\tThis favorable earnings is due to the splitting of "<<s[i].stock_name<<endl<<
	 "\tshares, thus increasing increasing the number of outstanding shares "<<endl<<
	 "\twithout diluting shareholders. This sharp rise has attracted numerous" <<endl
	 <<"\tshareholders to invest in the share."<<endl;
		}
		else if ((s[i].volume_available < 7000) && (s[i].volume_available >= 3000))
		{
cout<<"\t"<<s[i].stock_name<<" is reserving its streak in the moderate side due to the"<<endl<<
	"\tstagnant sales. Regional market has been rather inactive and sales"<<endl<<"\thave risen less than expected. The market has also been quiet due to"<<endl<< 
				"\tthe domination by banking sector rally."<<endl;
		}
		else
		{
cout<<"\t"<<s[i].stock_name<<" close out with a whimper, indicating weak revenue and "<<endl<<"\tearnings.  Sales have been rather poor and weakness in the regional "<<endl<< 
"\tmarket is expected to continue weighing down the stock with growth "<<endl<< "\tremaining at the downside."<<endl;
		}
	}
	else if (i==2)
	{
		if(s[i].volume_available < 3000)
		{
cout<<"\t"<<s[i].stock_name<<" has continued its bearish run and has obtained solid gain "<<endl<<"\tfrom its sales. Increase in local demand has contributed much to the"<<endl<<
"\trise in the company's sales. For the past few months, new branches"<<endl<<
"\twere blooming like mushrooms in various places, denoting much"<<endl<< 
"\tpositive growth."<<endl; 
		}
		else if ((s[i].volume_available < 7000) && (s[i].volume_available >= 3000))
		{
cout<<"\t"<<s[i].stock_name<<" stock is maintaining its stability with its market rising and"<<endl<< "\tdropping with little distinction, showing impressive resiliency."<<endl<< 
			"\tSpeculation has it that this share is in a well position to rise."<<endl;
		}
		else
		{
cout<<"\t"<<s[i].stock_name<<" stock continued to flounder after Food Maker Service Rating"<<endl<<"\tannounced a negative statement on the company's services. The stock"<<endl<<	"\tis experiencing some tired blown and showing more hang-tough"<<endl<<
				"\ttendencies. Recovery is only expected if it's led by favorable"<<endl<< 
				"\twindows dressing activities."<<endl; 
		}
	}
	else if (i==3)
	{
		if(s[i].volume_available < 3000)
		{
cout<<"\tWith fresh leads, "<<s[i].stock_name<<" are in the position of favorable "<<endl<< 
	       "\tearnings.  The company has also gained good reputation from its fast, "<<endl<< 
"\tefficient and friendly services, not to mention their excellent quality"<<endl<<
"\tproducts.  In short, the market is in its bearish mood."<<endl; 
		}
		else if ((s[i].volume_available < 7000) && (s[i].volume_available >= 3000))
		{
cout<<"\t"<<s[i].stock_name<<" closed in a stable manner, sustaining its point-sized. "<<endl<< 
		 "\tRevenues and earnings from the company has been dormant but in a "<<endl<< 
	 "\trather positive mode. The share has, in short, been showing quite "<<endl<<
		 "\tremarkable flexibility."<<endl;
		}
		else
		{
cout<<"\t"<<s[i].stock_name<<" share is in a bad prospect, with its regional market "<<endl<<
		"\tdemand experiencing offset decline. The slowing down of this stock has "<<endl<< 
		"\tmade itself one of the point-sized losers falling back with extremely "<<endl<<
		"\tlow capital. Furthermore, there was no fresh positive news to "<<endl<< 
		"\tboost sentiment."<<endl; 
		}
	}
	else if (i==4)
	{
		if(s[i].volume_available < 3000)
		{
cout<<"\tThe share of "<<s[i].stock_name<<" is running its bearish race, leading with "<<endl<< 
	"\texcellent growth in its sales. "<<s[i].stock_name<<" too has gain investors' "<<endl<<
              "\tconfidence with the launch of its recent multi- million MOBILE COFFEE "<<endl
<< "\tBEAN project. It is now marked as one of the most active stock in the "<<endl
<<"\tmarket."<<endl;
		}
		else if ((s[i].volume_available < 7000) && (s[i].volume_available >= 3000))
		{
cout<<"\tTaking a slow stride, "<<s[i].stock_name<<" is in its inert mood, still "<<endl<<
	"\tmaintaining its volume. The share has able to reserve its winning "<<endl<<
		     "\tstreak though, through some street sponsorship and favorable budgets."<<endl<< 
	"\tHowever, the market is to be inactive with the economic direction "<<endl<<"\tunderpinned."<<endl;   
		}
		else
		{
cout<<"\t"<<s[i].stock_name<<" is showing less favorable earnings in its volume and is not"<<endl<< "\tsitting well in the market. The drastic revert of the stock is the"<<endl<<
	 "\tresult of the competition given by other companies of the same nature."<<endl<<
			 "\tThe stock is now in a dire position to recover anytime soon."<<endl; 
		}
	}
	getch();
	s[i].Interface();
}

void main()
{
	Stock s[MAX],temp;
	// The followings only be activated to renew the stocks.
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	temp.Interface();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -