Help stuck :(

Ok guys/gals am trying to write this code that will approve you for a purchase of a car and depending your info it should give you the correct payments etc...however I just cant get it to work in the output of the elig function I cant get the function to pass the information inputted. Need some help since am clueless of what to do next :(

Thanks in advance. Juan



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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include <iostream>
#include<string>

using namespace std;





class Carloan
{
private:
    string applicantName;
    string coApplicantName;
    int creditScore1;
    int creditScore2;
    int months;
    int numberOfApplicants;
    double interest;
    double downPayment;
    double montlyPayment;
    double totalIncome;
    double vehicleSellingPrice;
    double totalVehiclePrice;
    double carTotalInterest;
    double creditScore3;
public:
    int Carloan::applicantsInfo(int,string,string,int,int,double);
    double Carloan::carAndCredit(int,int,int,double,double,int,double);
    double Carloan::priceMath();
    void Carloan::displayCarloanElig(string,string,double,int);
    
    
    
    

};

int Carloan::applicantsInfo(int numberOfApplicants, string applicantName, string coApplicantName, int creditScore1, int creditScore2, double totalIncome)
{
    cout << "Will there be one applicant or two?" << endl;
    cin >> numberOfApplicants;
     { 
       if (numberOfApplicants == 1)
         {
               cout << "Please enter the name of the applicant" << endl;
               cin >> applicantName ;
               cout << "Please enter the total income of the applicant after all payments" << endl;
               cin >> totalIncome ;
               cout << "Please enter the credit score of the applicant " << endl;
               cin >> creditScore1 ;
               cout << "   " << endl;
         }
       else
         {
               cout << "Please enter the name of the main applicant " << endl;
               cin >> applicantName ;
               cout << "Please enter the name of the Co Applicant" << endl;
               cin >> coApplicantName ;
               cout << "Please enter the total income of both applicants after all payments" << endl;
               cin  >> totalIncome ;
               cout << "Please enter the credit score of the applicants" << endl;
               cin >> creditScore1 ;
               cout << "Please enter the credit score of the Co Applicant" << endl;
               cin >> creditScore2 ;
               cout << "  " << endl;
               creditScore3 = ((creditScore1 + creditScore2)/2);
         }
         
         
  }                                                                                                     
}
double Carloan::carAndCredit(int numberOfApplicants,int creditScore1, int creditScore2, double creditScore3,double vehicleSellingPrice,int months, double downPayment)
{

    
      if (numberOfApplicants == 1)
       { 
         if ( creditScore1 < 500) 
           {
            interest= .2599;
           }
         else if ((creditScore1 >= 500) && (creditScore1 <=589))
           {
            interest= .1521;
           }
        else if ((creditScore1 >= 590) && (creditScore1 <= 619))
           {
            interest= .1184;
           }
        else if ((creditScore1 >= 620) && (creditScore1 <= 689))
           {
            interest = .8800;
           }
           
        else if ((creditScore1 >= 690) && (creditScore1 <= 719))
           {
            interest = .5890;
           }
        else
           {
            interest= .3890;
           }
        }
    else 
    
     {
        if (creditScore3 < 499)
           {
            interest= .2599;
           }
        else if ((creditScore3 >= 500) && (creditScore3 <=589))
        {
            interest= .1521;
        }
        else if ((creditScore3 >= 590) && (creditScore3 <= 619))
        {
            interest= .1184;
        }
        else if ((creditScore3 >= 620) && (creditScore3 <= 689))
        {
            interest = .8800;
        }
        else if ((creditScore3 >= 690) && (creditScore3 <= 719))
        {
            interest = .5890;
        }
        else 
         {
            interest= .3890;
         }
    }
    
    
    cout << "Please enter the total price of the vehicle. " <<endl;
    cin >> vehicleSellingPrice;
    cout << "Please enter the number of months you wish to finance the car for " << endl;
    cout << "The available months are 24, 36, 48, and 60." << endl;
    cin >> months;
    cout << " Will there be a downpayment? If not type 0." <<endl;
    cin >> downPayment;
    cout << "  " << endl;


}

double Carloan::priceMath()
{

      totalVehiclePrice = vehicleSellingPrice - downPayment;
      carTotalInterest = totalVehiclePrice * interest;
      montlyPayment = (totalVehiclePrice / months) + carTotalInterest;

return montlyPayment;
}
void Carloan::displayCarloanElig(string applicantName, string coApplicantName,double montlyPayment,int months)
{ 
    


    
    if (numberOfApplicants == 1)
    cout << "We are please to inform that " << applicantName <<  " has been approved for the loan." << endl;
    
    else
         cout << "We are please to inform that " << applicantName << " and "  << coApplicantName << " have been approved for the loan." << endl;
         

    cout << " The estimated montly payments are: " << montlyPayment << " for " << months << " months." << endl;
    cout << " We thank you for your business." << endl;

}




int main()
{
        
    


      Carloan aCarloan;
      aCarloan.applicantsInfo(1,"x","x",1,1,10.2);
      aCarloan.carAndCredit(1,1,1,1.1,1,1,1);
      aCarloan.displayCarloanElig("x", "x" ,0,0);
      
     
	  
	  system("PAUSE");
	  return 0;

    




}


Could you be a bit less vague? What behaviour are you actually seeing when you run this? How does it differ from the expected behaviour?
The program compiles and runs. It asks you for all of the information however at the end its suppose to output your name if your single applicant or the 2 names with a co applicant with the information of what your payment should be for the number of months you have selected but what its outputted its the information in which I call the function which is "x" "x" and "0" "0"

:(
what its outputted its the information in which I call the function which is "x" "x" and "0" "0"

Well, yes. You tell it to output the values of applicantName , coApplicantName , montlyPayment and months.

These are the names of the arguments that you pass into the method, so that's what it prints out.

Your argument names are, however, the same as your data member names, which is a silly thing to do, as it means your arguments are hiding the data members.

thank you!!! i deleted all of the arguments and it worked finally x)
You're welcome! Glad to hear it worked :)
Topic archived. No new replies allowed.