Code not outputting calculations

I'm having a problem with my code. It is getting the input from the text file but it is not doing the calculations I'm trying to do. If there is something wrong with this I would be very grateful if you could tell me. Thanks!!

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
 #include<iostream>
#include<string>
#include<fstream>
#include<iomanip>

using namespace std;

int main()
{
	const string INPUT_PROMPT = "Input filename?";
	ifstream acct_data;
	string lastName;
	int accountNum1;
	int accountNum2;
	int accountNum3;
	int accountNum4;
	int accountNum5;
	int accountNum6;
	double currentBal;
	double interestRate;
	double finalInt;
	double rev = 0;
	double updated = 0;
	string acct_dataFileName;
	int number;

	cout << INPUT_PROMPT;
	cin >> acct_dataFileName;
	cout << endl;

	acct_data.open(acct_dataFileName);

	acct_data >> lastName >> accountNum1 >> accountNum2 >> currentBal >> interestRate;
	finalInt = interestRate / 100;
	rev =rev * finalInt;
	updated = currentBal + rev;
	number = interestRate + 1;

	cout << setprecision(2) << fixed << showpoint << accountNum1 << accountNum2 << " " << lastName << "      " << updated << endl;

	acct_data >> lastName >> accountNum3 >> accountNum4 >> currentBal >> interestRate;
	finalInt = interestRate / 100;
	rev = rev * finalInt;
	updated = currentBal + rev;

	cout << setprecision(2) << fixed << showpoint << accountNum3 << accountNum4 << " " << lastName << "      " << updated << endl;

	acct_data >> lastName >> accountNum5 >> accountNum6 >> currentBal >> interestRate;
	finalInt = interestRate / 100;
	rev = rev  * finalInt;
	updated = currentBal + rev;

	cout << setprecision(2) << fixed << showpoint << accountNum5 << accountNum6 << " " << lastName << "      " << updated << endl;


	acct_data.close();

	system("pause");
	return 0;
}
What makes you think it's not doing the calculations? What behaviour are you seeing that differs from what you expect?
Hello fufusus,

Your program works, but with knowing what the "data file" looks like it is hard to say if it is working correctly. The lines "rev = rev * finalInt" "rev" will always be zero which may not be what you want.

Hope that helps,

Andy
Topic archived. No new replies allowed.