SnB Posted October 5, 2004 Share Posted October 5, 2004 Wow...this topic sure took a turn of subjects Quote Link to comment Share on other sites More sharing options...
CWSGuy406 Posted October 5, 2004 Author Share Posted October 5, 2004 The bad part about this is it caught me square. It didn't waver an inch and centered in. I'm icing my crotch at the moment. Ouch. Sometimes those soft tappers are the ones that hurt most... Quote Link to comment Share on other sites More sharing options...
santo=dorf Posted October 5, 2004 Share Posted October 5, 2004 I was forced to take CS 101 last fall, and it was the worst class ever!!! COMPUTER SCIENCE IS NOT A f***ING SCIENCE!!!! :fyou C Quote Link to comment Share on other sites More sharing options...
DonkeyKongerko Posted October 5, 2004 Share Posted October 5, 2004 The type double is used for numbers with decimals while the type string is for words. You probably know this but just in case you didn't notice you had stockname set as a double. I use the setw() function to space out my output. It's alot easier than typing a bunch of spaces. Just make sure you include iomanip first. The rest of this is pretty basic, you change the value NUMSTOCKS if you want your program to have more stocks. Have you guys done loops yet? This program is alot easier if you use them. You won't have to type the same lines over and over again. The amount gain/lost is a simple multiplication and you can just put that in a new column on the table. I'm a CS major so I love doing this stuff. If there are any CS haters out there, just think about the people that make places like Soxtalk possible the next time you visit. #include <iostream> #include <iomanip> #include <string> using namespace std; const int NUMSTOCKS = 2; int main() { string username; string date; string stocknames[NUMSTOCKS]; double stockopens[NUMSTOCKS]; double stockcloses[NUMSTOCKS]; double stockshares[NUMSTOCKS]; cout<<"What is your name?"<<endl; cin>>username; cout<<"What is today's date?"<<endl; cin>>date; for(int i=0; i<NUMSTOCKS; i++) { cout << "Stock " << i+1 << " : Name?"<<endl; cin >> stocknames[i]; cout << "Stock " << i+1 << " : Opening Value?"<<endl; cin >> stockopens[i]; cout << "Stock " << i+1 << " : Closing Value?"<<endl; cin >> stockcloses[i]; cout << "Stock " << i+1 << " : # of Shares?"<<endl; cin >> stockshares[i]; } cout << "Name"<< setw(18) << "Open Price"<< " " << "Closing Price"<< " "<< "# of Shares"<<endl; for(int i=0; i < NUMSTOCKS; i++) { cout << stocknames[i]<< setw(18-stocknames[i].length()) << stockopens[i] << setw(11) << stockcloses[i] << setw(13) << stockshares[i] <<endl; } return 0; } Quote Link to comment Share on other sites More sharing options...
witesoxfan Posted October 5, 2004 Share Posted October 5, 2004 I'm just doing Java right now. That stuff looks Greek to me. I understand it's probably not that hard, but still. I'm personally wondering when we'll get into C++. cws and soxn...what was the class that you are doing this in(like its actual name)? Quote Link to comment Share on other sites More sharing options...
AssHatSoxFan Posted October 5, 2004 Share Posted October 5, 2004 where is the bigint love??????? Quote Link to comment Share on other sites More sharing options...
SnB Posted October 5, 2004 Share Posted October 5, 2004 The type double is used for numbers with decimals while the type string is for words. You probably know this but just in case you didn't notice you had stockname set as a double. I use the setw() function to space out my output. It's alot easier than typing a bunch of spaces. Just make sure you include iomanip first. The rest of this is pretty basic, you change the value NUMSTOCKS if you want your program to have more stocks. Have you guys done loops yet? This program is alot easier if you use them. You won't have to type the same lines over and over again. The amount gain/lost is a simple multiplication and you can just put that in a new column on the table. I'm a CS major so I love doing this stuff. If there are any CS haters out there, just think about the people that make places like Soxtalk possible the next time you visit. #include <iostream> #include <iomanip> #include <string> using namespace std; const int NUMSTOCKS = 2; int main() { string username; string date; string stocknames[NUMSTOCKS]; double stockopens[NUMSTOCKS]; double stockcloses[NUMSTOCKS]; double stockshares[NUMSTOCKS]; cout<<"What is your name?"<<endl; cin>>username; cout<<"What is today's date?"<<endl; cin>>date; for(int i=0; i<NUMSTOCKS; i++) { cout << "Stock " << i+1 << " : Name?"<<endl; cin >> stocknames[i]; cout << "Stock " << i+1 << " : Opening Value?"<<endl; cin >> stockopens[i]; cout << "Stock " << i+1 << " : Closing Value?"<<endl; cin >> stockcloses[i]; cout << "Stock " << i+1 << " : # of Shares?"<<endl; cin >> stockshares[i]; } cout << "Name"<< setw(18) << "Open Price"<< " " << "Closing Price"<< " "<< "# of Shares"<<endl; for(int i=0; i < NUMSTOCKS; i++) { cout << stocknames[i]<< setw(18-stocknames[i].length()) << stockopens[i] << setw(11) << stockcloses[i] << setw(13) << stockshares[i] <<endl; } return 0; } i know loops, but from what i could tell CWSGuy wouldn't know what the hell i was talking about. Thought i'd give ihm the beginner version first. Quote Link to comment Share on other sites More sharing options...
DBAHO Posted October 5, 2004 Share Posted October 5, 2004 Here's a barebones program, the table won't work because i can't remember how to space correctly....and you might need to make some changes to the variable types (don't know if string will work w/ your compiler) but this should give yo uan idea. String username; String date; Double Stock1name; Double Stock1open; Double Stock1close; Double Stock1shares; Double Stock2name; Double Stock2open; Double Stock2close; Double Stock2shares; Double Stock3name; Double Stock3open; Double Stock3close; Double Stock3shares; int main() { cout cin>>username; cout cin>>date; cout cin>>stock1name; cout cin>>stock1open; cout cin>>stock1close; cout cin>>stock1shares; cout cin>>stock2name; cout cin>>stock2open; cout cin>>stock2close; cout cin>>stock2shares; cout cin>>stock3name; cout cin>>stock3open; cout cin>>stock3close; cout cin>>stock3shares; cout cout cout cout return 0; } I did that type of s*** last year, when I did a college I.T course in my last year of high school. We used VB.NET though. Quote Link to comment Share on other sites More sharing options...
DBAHO Posted October 5, 2004 Share Posted October 5, 2004 i know loops, but from what i could tell CWSGuy wouldn't know what the hell i was talking about. Thought i'd give ihm the beginner version first. Where were you last year when I needed your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.