loop from input text file

I am having trouble performing a loop from an input text file, here is what I have so far:


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
//preprocessor directives
#include<iostream>
#include<fstream>
#include<iomanip>
//step 1

using namespace std;
int main(){
    system("color f0");
    
    cout<<"=******************************************="<<endl;
    cout<<"*   IT210 Business Applications with C++   *"<<endl;
    cout<<"*   Programmer: Richard Hoang              *"<<endl;
    cout<<"*   Date: October 15, 2015                 *"<<endl;
    cout<<"*   Assignment 2 - Interest Calculator     *"<<endl;
    cout<<"=******************************************="<<endl;
    
    //declare objects of type ifstream and ofstream
    ifstream fin;
    ofstream fout;
    
    //open fin and fout or associate files with fin and fout
    fin.open("customer.txt");
    fout.open("output.txt");
    
    //error check fin and fout
    if(!fin){
             cout<<"Input failure/n";
             system("pause");
             return 1;
             }//end of fin error check
             
    if(!fout){
              cout<<"Output failure/n";
              system("pause");
              return 1;
              }//end of fout error check
              
    cout<<"Successfully opened input/output files"<<endl;
    //execute at this stage always
    
    cout<<endl;
    cout<<endl;
    
    cout<<"This program calculates the interest on unpaid"<<endl;
    cout<<"credit card balances using the average daily balance"<<endl;
    cout<<"and the total interest owed to the Bank"<<endl;
    
    cout<<endl;
    cout<<endl;
    
    
    //read from input text files
    string firstName;
    string lastName;
    int credit;
    float netBalance;
    float payment;
    int d1;
    int d2;
    float averageDailybalance;
    float interest;
    float APR;
    
    
    //output to monitor and text files
    cout<<"************************************************************"<<endl;
    cout<<"123456789012345678901234567890123456789012345678901234567890"<<endl;
    cout<<"************************************************************"<<endl;
    cout<<left<<setw(20)<<"FULL NAME"<<setw(13)<<"CARD #"<<setw(10)<<"BALANCE"<<
    setw(9)<<"APR (%)"<<setw(8)<<"INTEREST"<<endl;
    cout<<"------------------------------------------------------------"<<endl;
    
    
    
    while(fin){
                   
    //step 4
    fin>>firstName>>lastName>>credit>>netBalance>>payment>>d1>>d2;
    
    averageDailybalance=(netBalance*d1-payment*d2)/d1;
    
    if(averageDailybalance<=100.00){
                    APR="5.0/n";
                    
  

                    system("pause");
                    return 1;
                    }
    
    interest=averageDailybalance*(APR/100.0*12.0);
    

    
    cout<<left<<setw(20)<<firstName<<setw(10)<<credit<<setw(10)<<right<<fixed<<setprecision(2)
    <<netBalance<<setw(10)<<APR<<setw(10)<<interest<<endl;
    
    fout<<left<<setw(20)<<firstName<<setw(10)<<credit<<setw(10)<<right<<fixed<<setprecision(2)
    <<netBalance<<setw(10)<<APR<<setw(10)<<interest<<endl;
    
    if(fin.peek()=='\n')fin.ignore();
    }//end of fin controlled while
    
   

    //fin.close fin and fout
    fin.close();
    fout.close();
    
    
    cout<<"------------------------------------------------------------"<<endl;
    
    cout<<endl;
    cout<<endl;
    cout<<"12345678901234567890123456789012345678901234567890"<<endl;
    cout<<"**************************************************"<<endl;
    cout<<endl;
    cout<<endl;
    cout<<"Total interest owed to Bank is $"<<interest;
    cout<<endl;
    cout<<endl;
    cout<<"**************************************************"<<endl;
    cout<<endl;
    cout<<endl;
    
    system("pause");
    return 0;
    
    
    
}//end of main 


My main problem is with
1
2
3
4
5
6
7
8
9
10
11
12
 averageDailybalance=(netBalance*d1-payment*d2)/d1;
    
    if(averageDailybalance<=100.00){
                    APR="5.0/n";
                    
  

                    system("pause");
                    return 1;
                    }
    
    interest=averageDailybalance*(APR/100.0*12.0);


how do I set the parameters for assigning a value for APR depending on average daily balance?
Topic archived. No new replies allowed.