Jump to content

I Need Some Help!


CWSGuy406

Recommended Posts

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...

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

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;

}

:o :huh: :unsure:

Link to comment
Share on other sites

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;

}

:blink: :blink: :wacko:

Link to comment
Share on other sites

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;

}

:huh: :o

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;
}

 

:huh

Link to comment
Share on other sites

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. :D

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...