Group project is in danger here

Having problems with the inputStock function. it runs by itself but will not input to the variables in the class so that they are usable. It feels like I am missing a whole step here somewhere. This is the data for the input file called Stocks.txt:

ABC 123.45 130.95 132.00 125.00 120.50 8.67% 10000
AOLK 80.00 75.00 82.00 74.00 83.00 -9.64% 5000
CSCO 100.00 102.00 105.00 98.00 101.00 0.99% 25000
IBD 68.00 71.00 72.00 67.00 75.00 -5.33% 15000
MSET 120.00 140.00 145.00 140.00 115.00 21.74% 30920

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <string>
using namespace std;

class stockType
{
public:
       void inputStock (char, double, double, double, double, double, double);
       void setStock (char, double, double, double, double, double, double);
       void getStock (char&, double&, double&, double&, double&, double&, double&)const;
       void printStock() const;
       void showPriceDiff();
       double calcPercentGain();
       double showShares(); 
       friend istream& operator >> (istream &in, const stockType &cStock);
       friend ostream& operator<< (ostream &out, const stockType &cStock);
       double getTotalAssets();
       stockType(char, double, double, double, double, double, double);
       stockType();

        char ss;
        double op, cp, th, tl, pc, sv;
        double total_assets;
};
void stockType::inputStock (char symbol, double openingPrice, double closingPrice, 
double todayHigh, double todayLow, double prevClose, double volume)
{
ifstream infile("Stocks.txt");
string line;
if( infile.is_open() )
    {
     while( getline(infile,line) )
       {
            cin >> symbol;
            cin >> openingPrice;
            cin >> closingPrice;
            cin >> todayHigh;
            cin >> todayLow;
            cin >> prevClose;
            cin >> volume;
       
       }
     }
}
void stockType::setStock (char symbol, double openingPrice, double closingPrice, 
double todayHigh, double todayLow, double prevClose, double volume)
{
                                                                                  //*
      ss = symbol;                                                                //*
                                                                                  //*
      op = openingPrice;                                                          //*
                                                                                  //*
      cp = closingPrice;                                                        //*
                                                                                  //*
      th = todayHigh;                                                             //*
                                                                                  //*
      tl = todayLow;                                                              //*
                                                                                  //*
      pc = prevClose;                                                             //*
                                                                                  //*
      sv = volume;                                                                //*
                                                                                  //*
}

void stockType::getStock(char& symbol, double& openingPrice, double& closingPrice, 
double& todayHigh, double& todayLow, double& prevClose, double& volume) const 
{ 
     symbol = ss; openingPrice = op; closingPrice = cp; todayHigh = th;
     todayLow = tl; prevClose = pc; volume = sv;
}



void stockType::printStock() const 
{ 
       cout << ss; 
       cout << op;
       cout << cp;
       cout << th;
       cout << tl;
       cout << pc;
       cout << sv; 
} 

void stockType::showPriceDiff()
{                                                                                      //*
cout << "Today's opening price was " << op << ", and the closing was " << cp << endl;  //*
cout << "Today's high price was " << th << ", and the low price was " << tl << endl;   //*
cout << "While the previous closing price was " << pc << endl;                         //*
}                                                                                      //*
double stockType::calcPercentGain()                                                    //*
{                                                                                      //*
return (cp - pc) / pc * 100;                                                           //*
}
double stockType::showShares()
{
return sv;     
}     
istream& operator >> (istream &in, stockType &cStock)

{

// Since operator>> is a friend of the stockType class, we can access StockType members directly.

       in >> cStock.ss;

       in >> cStock.op;

       in >> cStock.cp;

       in >> cStock.th;

       in >> cStock.tl;

       in >> cStock.pc;

       in >> cStock.sv;

       // cout << cStock.total_assets << endl;

       //*& cStock.total_assets += cStock.sv*cStock.pc;

       return in;
}
ostream& operator<< (ostream &out, stockType &cStock)

{

       cStock.calcPercentGain();

// operator<< is a friend of the StockType class, we can access StockTypes members directly.

       cout << setw(8) << left << cStock.ss << right << fixed << setprecision(2) << setw(8) <<

              cStock.op << fixed << setprecision(2) << setw(8) <<

              cStock.cp << fixed << setprecision(2) << setw(8) <<

              cStock.th << fixed << setprecision(2) << setw(8) <<

              cStock.tl << fixed << setprecision(2) << setw(8) <<

              cStock.pc << fixed << setprecision(2) << setw(12) <<

              cStock.sv << fixed << setprecision(2) <<endl;

       return out;

}
double stockType::getTotalAssets()

{ 

return 0.0;
}
stockType::stockType(char symbol, double openingPrice, double closingPrice, 
double todayHigh, double todayLow, double prevClose, double volume)
{
      if ('A' <= symbol && symbol < 'z') 
      ss = symbol; else ss = ' '; 
      if (0 <= openingPrice && openingPrice < 9999) 
      op = openingPrice; 
      else op = 0; 
      if (0 <= closingPrice && closingPrice < 9999) 
      cp = closingPrice; 
      else cp = 0;
      if (0 <= todayHigh && todayHigh < 9999)
      th = todayHigh;
      else th = 0;
      if (0 <= todayLow && todayLow < 9999)
      tl = todayLow;
      else tl = 0;
      if (0 <= prevClose & prevClose < 9999)
      pc = prevClose;
      else pc = 0;
      if (0 <= volume && volume < 999999)
      sv = volume;
      else sv = 0;
}
stockType::stockType() 
{ 
    ss = 'A'; 
    op = 0; 
    cp = 0;
    th = 0;
    tl = 0;
    pc = 0;
    sv = 0; 
};

int main()
{
stockType stock;
stock.printStock();
 system ("pause");
 return 0;    
}   

Any help at all would be greatly appreciated.
You are doing something strange inside that method. You read a line, then, instead of processing that line, continue to read from the file... What is your goal? If you step through that function with a debugger you will be able to see exactly what is going on with the variables.
My goal is to input all the data into variables so that they can be printed out as a report. They will be put into a report that shows all the stocks and then prints then out as a report that shows the percentage gain or loss. I just can't figure how to get the file translated into data that I can use.

Sorry so stupid, but I do not mind insults as long as I can get this project going.

Thank you all in advance,
dragonfly95670
Topic archived. No new replies allowed.