Apr 12, 2017 at 11:32pm
Idk how to add the calculateCost from the other sub classes and base class together. Help.
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
|
void PackageInventory::CalculateTotalCost()
{
cout << "\n____________________________________________\n";
cout << "\nCalculating Total Cost\n";
for(int i=0; i < packages.size(); i++)
{
cout << packages[i].calculateCost();
cout <<endl;
}
for(int i=0; i < expressPackages.size(); i++)
{
cout << expressPackages[i].calculateCost();
cout <<endl;
}
for (int i=0; i<priorityPackages.size(); i++)
{
cout << priorityPackages[i].calculateCost();
cout <<endl;
}
for (int i=0; i<internationalPackages.size(); i++)
{
cout << internationalPackages[i].calculateCost();
cout <<endl;
}
}
|
This is the output:
Calculating Total Cost
4.25
12.00
40.90
33.08
196.78
79.40
74.62
12.00
18.00
30.00
0.00
65.00
0.00
11.97
165.00
154.00
335.00
I want these numbers to add together giving me one number for the sum of all of them
Last edited on Apr 12, 2017 at 11:33pm
Apr 13, 2017 at 12:51am
I did it that way but it did not work it still printed the same thing
Apr 13, 2017 at 1:23am
it says my program is too long :,,(
Apr 13, 2017 at 1:28am
this function by itself seems OK, the problem is elsewhere in the program.