這個Crypto小程式會依照上面ATM的概念作延伸。
來列舉一下想要添加的功能:
因為是簡單介紹就不多做其他功能例如bid price spread等等的運算。
先簡單做出一個目錄:
cout << "*****MENU*******" <<endl;
cout << "1.Show Current Price" << endl;
cout << "2.Find Crypto info" << endl;
cout << "3.Find Market Cap" << endl;
cout << "4.Help" << endl;
cout << "5.Exit" << endl;
cout << "****************" << endl;
第一個選項會在另一篇專門說明,因為會用到File handling佔的篇幅比較多。
接下來輸入我們的選擇,用cin >>
int option;
cout << "Type the service you'd like to do: " << endl;
cin >> option;
int option;
cout << "Type the service you'd like to do: " << endl;
cin >> option;
do{
switch(option){
case 1:
{
cout << "Enter the Crypto (1.BTC, 2.ETH, 3.USDT 4. Exit):"<<endl;
int cname;
cin >> cname;
cout << "You entered: " << cname << endl;
break;
}
case 2:
{
cout <<"Enter the name of the crypto you'd like to see info with:" << endl;
cout << "1.BTC, 2.ETH, 3.USDT 4. Exit" << endl;
int x;
cin >> x;
cout << "you entered: " << x<< endl;
break;}
case 3:
{ cout <<"Enter the crypto you'd like to see Market Cap with:" << endl;
cout << "1.BTC, 2.ETH, 3.USDT 4. Exit" << endl;
int y;
cin >> y;
cout << "Market cap is: $" << marketcap(y) << endl;
break;}
case 4:
cout <<"Need Help? Don't worry! We're here for you" << endl;
break;
}
}while (option != 5);
預期功能:輸入編號會顯示出該虛擬幣的資訊,包含現有流通樹木與第一個區塊創建時間(上市時間)。
1.BTC, 2.ETH, 3.USDT 4. Exit
if(c == 1){
cout << "Total Bitcoin: 19,166,487 BTC" << endl;
cout << "First Block(Bitcoin creation date): 2009-01-09" << endl;
}else if(c == 2){
cout << "Total ETH: 122,690,161 ETH" << endl;
cout << "First Block(ETH creation date): July 30, 2015
" << endl;
}else cout << "Total USDT: 68,212,574,446 USDT" << endl;
cout << "Tether was created as an attempt to solve two major issues with existing cryptocurrencies: high volatility and convertibility between fiat currencies and cryptocurrencies. To address these perceived issues Tether created a cryptocurrency that is fully backed 1:1 by deposits of U.S. dollars held at banks." << endl;
預期功能:輸入編號會顯示出該虛擬幣的資本市值。
這邊想用輸出數字,long int
當輸出值。稍後把它做到function裡面。
1.BTC, 2.ETH, 3.USDT 4. Exit
if(c == 1){
long int mbtc = 367982010627;
return mbtc;
}else if(c == 2){
long int meth = 163879592332;
return meth;
}else if(c == 3){
long int musdt = 68269066618;
return musdt;
}else
return 0;
}
預期功能:顯示聯絡方式與常見問題。
cout <<"Telephone: 120-332-593. Email: crypto-servie@cryptobot.com Open:Mon-Fri AM9:00~PM4:30"<< endl;
Reference: w3school, geeksforgeeks, CodeBeauty(YouTube)