October 5, 200421 yr I need a lot of help with this. I need to write a program in C++ that calculates stocks and places them into a table-like format. Can someone help me out? And, perhaps teach me a little bit of it too? I would really appreciate, I've only missed one class this year, and I'm totally lost. I have no clue what the hell we're doing... Anyways, here's the program I need to write... (Alignment may be off.) "Create a program that lists a stock portfolio from the prior day. Have the user input his or her name, today's date, and information about 3 stocks (stock name, its opening value for yesterday, its closing value for yesterday, and the amount of shares owned). Use decimals and integer. Create a table of information as output. The table should look as follows: D A's Portfolio 1/28/03 (previous day) Stock Name Opening Value Closing Value Shares Amount Gained/Lost Toys R Us 15 18 100 +300 Microsoft 26 25.5 50 -25 Mobil 27 31 200 +475 Totals We've been using strcpy's, strcat's, chars, ints, floats, cin's, cout's, and I have absolutely no f***ing clue what any of it means. And I can't take the class Pass/Fail, so - because I have a C in the class, it means my class rank of 26th is going to drop, and I'm so f***ing pissed. I need to understand this s*** ASAP...
October 5, 200421 yr 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; }
October 5, 200421 yr 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; }
October 5, 200421 yr 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<<"What is your name?<<endl; cin>>username; cout<<"What is today's date?"<<endl; cin>>date; cout<<"Stock 1: Name?"<<endl; cin>>stock1name; cout<<"Stock 1: Opening Value?"<<endl; cin>>stock1open; cout<<"Stock 1: Closing Value?"<<endl; cin>>stock1close; cout<<"Stock 1: # of Shares?"<<endl; cin>>stock1shares; cout<<"Stock 2: Name?"<<endl; cin>>stock2name; cout<<"Stock 2: Opening Value?"<<endl; cin>>stock2open; cout<<"Stock 2: Closing Value?"<<endl; cin>>stock2close; cout<<"Stock 2: # of Shares?"<<endl; cin>>stock2shares; cout<<"Stock 3: Name?"<<endl; cin>>stock3name; cout<<"Stock 3: Opening Value?"<<endl; cin>>stock3open; cout<<"Stock 3: Closing Value?"<<endl; cin>>stock3close; cout<<"Stock 3: # of Shares?"<<endl; cin>>stock3shares; cout<<"name "<<"Open Price "<<"Closing Price "<<"# of Shares"<<endl; cout<<stock1name<<" "<<stock1open<<" "<<stock1close<<" "<<stock1share<<endl; cout<<stock2name<<" "<<stock2open<<" "<<stock2close<<" "<<stock2share<<endl; cout<<stock3name<<" "<<stock3open<<" "<<stock3close<<" "<<stock3share<<endl; return 0; }
October 5, 200421 yr 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; }
October 5, 200421 yr it's really not that hard guys i did it in like 10 minutes. And this is why I can't go to U of I. Not that I would if I could.
October 5, 200421 yr 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; } Umm
October 5, 200421 yr 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<<"What is your name?<<endl; cin>>username; cout<<"What is today's date?"<<endl; cin>>date; cout<<"Stock 1: Name?"<<endl; cin>>stock1name; cout<<"Stock 1: Opening Value?"<<endl; cin>>stock1open; cout<<"Stock 1: Closing Value?"<<endl; cin>>stock1close; cout<<"Stock 1: # of Shares?"<<endl; cin>>stock1shares; cout<<"Stock 2: Name?"<<endl; cin>>stock2name; cout<<"Stock 2: Opening Value?"<<endl; cin>>stock2open; cout<<"Stock 2: Closing Value?"<<endl; cin>>stock2close; cout<<"Stock 2: # of Shares?"<<endl; cin>>stock2shares; cout<<"Stock 3: Name?"<<endl; cin>>stock3name; cout<<"Stock 3: Opening Value?"<<endl; cin>>stock3open; cout<<"Stock 3: Closing Value?"<<endl; cin>>stock3close; cout<<"Stock 3: # of Shares?"<<endl; cin>>stock3shares; cout<<"name "<<"Open Price "<<"Closing Price "<<"# of Shares"<<endl; cout<<stock1name<<" "<<stock1open<<" "<<stock1close<<" "<<stock1share<<endl; cout<<stock2name<<" "<<stock2open<<" "<<stock2close<<" "<<stock2share<<endl; cout<<stock3name<<" "<<stock3open<<" "<<stock3close<<" "<<stock3share<<endl; return 0; }
October 5, 200421 yr There, now you've got the geekiness working. In other news, between the time school ended and 6PM, I've been nailed in the nuts with a tennis ball and in a minor car accident. The tennis ball was worse....
October 5, 200421 yr I've been in a minor car accident and nailed in the nuts with a tennis bal. That sucks about the car accident. But the 2nd part is just hilarious.
October 5, 200421 yr Nah, I was just rding in a car with a girl.....she stopped behind another car.....and then she let her foot off the brake because she thought the car ahead went. Just bumped bumpers, but I threatened to sue nonetheless. A friend of mine threw the tennis ball at me. He was joking around, and I guess he thought I could elude the green orb of death. I didn't, and I'm still feeling it in the testicle area.
October 5, 200421 yr 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.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.