Skip to content
View in the app

A better way to browse. Learn more.

Soxtalk.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

I Need Some Help!

Featured Replies

Wow...this topic sure took a turn of subjects :lol:

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

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

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. :headbang 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'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)?

where is the bigint love??????? :wub:

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

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.

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. ;) :lol:

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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.