Dec 2, 2009 at 8:35am UTC
#include <stdafx.h>
#include <iostream>
using namespace std;
double calcLatefee(double, double);
int main ()
{
double overDue,
creditAmount,
surFee ;
cout << " Amount? ";
cin >> creditAmount;
cout << "Days past due? ";
cin >> overDue ;
lateFee = calcsurfee(double, double) ;
return 0 ;
}
double calcsurfee(double, double)
{if ( overDue >= 60 )
{
if ( creditAmount >= 10 || creditAmount < 50)
{
return 20 ;
}
else if ( creditAmount >= 50 || creditAmount < 100)
{
return 15 ;
}
else if ( creditAmount >= 100 || creditAmount < 250)
{
return 30 ;
}
else
{
return 70 ;
}
}
else if ( overDue >= 30)
{
if ( creditAmount >= 10 || creditAmount < 50)
{
return 10 ;
}
else if ( creditAmount >= 50 || creditAmount < 100 )
{
return 70 ;
}
else if ( creditAmount >= 100 || creditAmount < 250)
{
return 15 ;
}
else
{
return 35 ;
}
}
cout << "\nA Credit amount of " << creditAmount << " is " << overDue << " late" << "\n";
cout << "\nA fee is: " << lateFee << " dollars " "\n" ;
return 0 ;
}
Last edited on Dec 2, 2009 at 8:46am UTC
Dec 2, 2009 at 12:44pm UTC
Here are some mistakes fixed which I found at the first watch.
Next time use the source-tags to quote code and also post a discription the errors which occur.
And maybe yes, read the post which kbw linked before ;)
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
int main ()
{
double overDue, creditAmount, surFee ;
cout << " Amount? " ;
cin >> creditAmount;
cout << "Days past due? " ;
cin >> overDue ;
// call function not with "double", use the variable name
// lateFee is not defined, you mean surFee?
surFee = calcsurfee(creditAmount, overDue ) ;
// I think you have to make this output here, because your
// function don't know something about surFee/lateFee
cout << "\nA Credit amount of " << creditAmount << " is " << overDue << " late" << "\n" ;
cout << "\nA fee is: " << surFee << " dollars " << "\n" ;
return 0 ;
}
// You have to give names to input variables of a function
double calcsurfee(double creditAmount, double overDue )
{
if ( overDue >= 60 )
{
/* If you want a value beetween 2 numbers take && instead of ||
* for example 100 in if ( creditAmount >= 10 || creditAmount < 50)
* would bring the result (true || false) which is true
* Taking &&: (true && false) is false
*/
if ( creditAmount >= 10 && creditAmount < 50)
{
return 20 ;
}
else if ( creditAmount >= 50 && creditAmount < 100)
{
return 15 ;
}
else if ( creditAmount >= 100 && creditAmount < 250)
{
return 30 ;
}
else
{
return 70 ;
}
}
else if ( overDue >= 30)
{
if ( creditAmount >= 10 && creditAmount < 50)
{
return 10 ;
}
else if ( creditAmount >= 50 && creditAmount < 100 )
{
return 70 ;
}
else if ( creditAmount >= 100 && creditAmount < 250)
{
return 15 ;
}
else
{
return 35 ;
}
}
return 0 ;
}
Last edited on Dec 3, 2009 at 7:46am UTC