Inventory program

closed account (oN3k92yv)
I made an inventory program, but I'm having trouble having it display the COMPLETE TOTAL. How would I get all the values to add up to the complete total?

this is how it looks http://i.imgur.com/CprjHga.png

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
  /*This program calculates inventory data*/

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	string tool;
	double unitCost;
	double numberOfUnits;
	double totalCost = 0;
	char ch = ' ';
	bool done = false;
	ifstream input;
	int count = 0;
	double totalValue = 0;
	double completeTotal = 0;

	ifstream inFile;
	ofstream outFile;

	cout << fixed << setprecision(2);

	inFile.open("janeInventory1.txt");

	if (!inFile)
	{
		cout << "Cannot open input file. Program Terminates! " << endl;

		return 1;
	}

	outFile.open("janeInventory1.out");

	for (int i = 0; i < 6; i++)
	{
		cout << " " << (char)220;
	}

	outFile << fixed << showpoint << setprecision(2);
	inFile >> tool >> numberOfUnits >> unitCost;


	cout << "**************************************************************************" << endl;
	cout << "Inventory for Jane Doe National Hardware " << endl;
	cout << "**************************************************************************" << endl;
	cout << endl;
	cout << "ITEM		  NUMBER OF UNITS    UNIT COST ($)    TOTAL VALUE " << endl;
	cout << "***************************************************************************" << endl;

	ch = ' ';

	while (inFile)
	{
		inFile >> tool >> numberOfUnits >> totalCost;
		totalValue = numberOfUnits * unitCost;
		completeTotal = totalValue;

		cout << left << setw(10) << tool
			<< right << setw(15) << numberOfUnits
			<< right << setw(25) << unitCost
			<< right << setw(25) << totalValue
			<< "\n";

	}

	cout << "Inventory Total($): " << completeTotal << endl;
	










}


Last edited on
closed account (48T7M4Gy)
62: completeTotal += totalValue;
Last edited on
Topic archived. No new replies allowed.