had program working, still does, but outputs random numbers

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
void value(Stock partsList[], int size)
{
  double value = 0, total = 0; // tracks

  cout << "                              Inventory Report";
  cout << endl << endl;
  cout
    << " Item           Manufacturer         Quantity         Cost Each     "
    << "Total Value"
    << endl;
  for(int i=0; i < size; i++)
    {
      value = (partsList[i].cost) * (partsList[i].quantity);

      cout << left << setw(20) <<  partsList[i].name
           << left << setw(13) << partsList[i].mfg
           << right << setw(10) << partsList[i].quantity;
      cout << setprecision(2) << fixed;
      cout << right << setw(8) << "$" << setw(7) << partsList[i].cost;
      cout << right << setw(8) << "$" << setw(8) << value << endl;
      total += value;
    }
  cout << endl << endl
       << "Total value of all items: $" << total << endl
       << "Press enter to continue...";
  cin.get();
}
  


output
                             0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                  415241634       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                  318057880       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                  319296048       $   0.00       $    0.00
                                  321392640       $   0.00       $    0.00
                                     528384       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                  415236096       $   0.00       $    0.00
                                          0       $   0.00       $    0.00
                                 1979744064       $   0.00       $    0.00
                                 -2144533744       $   0.00       $   -0.00
                                 -2144533744       $   0.00       $   -0.00
                                 -2144533552       $   0.00       $   -0.00
                                 -2144533648       $   0.00       $   -0.00
                                 -2144534480       $   0.00       $   -0.00
AC_Motor            GE                   10       $   5.00       $   50.00
Amplifier           GE                   50       $   1.34       $   67.00
Capacitor           Ohmite               72       $   0.73       $   52.56
Chassis             Westinghouse         60       $  30.00       $ 1800.00
Connector           Ohmite              150       $   0.05       $    7.50
Coreless_Coil       Westinghouse         34       $   5.75       $  195.50
Crystal             GE                  350       $   0.45       $  157.50
DC_Motor            GE                   10       $   5.25       $   52.50
Diode               Ohmite              250       $   0.03       $    7.50
Fuse                Ohmite              400       $   0.18       $   72.00
Inductor            Ohmite              130       $   0.10       $   13.00
LED                 GE                  500       $   0.02       $   10.00
Multimeter          GE                    4       $  25.00       $  100.00
Oscilloscope        EBrand                2       $ 100.00       $  200.00
Relay               Ohmite              200       $   0.10       $   20.00
Resistor            Ohmite              100       $   0.05       $    5.00
Solder              EBrand              200       $   3.00       $  600.00
Soldering_Iron      Westinghouse         50       $   5.50       $  275.00
Stepper_Motor       GE                    7       $   8.00       $   56.00
Switch              Ohmite              143       $   1.67       $  238.81
Transistor          GE                  104       $   0.23       $   23.92
Vacuum_Tube         Westinghouse          2       $   0.00       $    0.00


specifically this part. Can you guys see anything?
This function only prints the data it's given.
I'd say your best bet is to use the debugger in your IDE and see what's in the data you send to this function just before you call value(, I suspect the problem is not in the above code.
Topic archived. No new replies allowed.