Firstly, a serious syntax error caused by copying and pasting code:
int main()
{
float CalcInterest(int AccountNumber);
};
(1) CalcInterest()
, , parens :
CalcInterest(5);
, , , , ( , . , , , : CalcInterest
float
int
, AccountNumber
. ? ++ .
:
float CalcInterest(int AccountNumber) {
int AccountNumber[8] = { 1001, 7940, 4382, 2651, 3020, 7168, 6245, 9342 };
if (AccountNumber == 1001 ) { }
, (re) AccountNumber
int
8
, int AccountNumber
, , 1001
int AccountNumber[8]
. :
main.cpp: In function 'float CalcInterest(int)':
main.cpp:21:24: error: declaration of 'int AccountNumber [8]' shadows a parameter
int AccountNumber[8] = { 1001, 7940, 4382, 2651, 3020, 7168, 6245, 9342 };
^
main.cpp:33:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (AccountNumber == 1001 || AccountNumber == 4382 || AccountNumber == 3020 || AccountNumber == 6245)
^
, , for
. , return
, ! , ?
, , for ? :
#include <iostream>
using namespace std;
void CalcInterest(int i);
int main()
{
cout << "Account Number\t" << "Balance\t\t" << "Days\t" << "Interest\t" << endl;
for (int account = 0; account < 8; account++) {
CalcInterest(account);
}
system("pause");
return 0;
};
void CalcInterest(int i) {
static const float Balance[8] = { 4254.40, 27006.25, 123.50, 85326.92, 657.0, 7423.34, 4.99, 107864.44 };
static const int DaysSinceDebited[8] = { 20, 35, 2, 14, 5, 360, 1, 45 };
static const int AccountNumbers[8] = { 1001, 7940, 4382, 2651, 3020, 7168, 6245, 9342 };
int interest = 0;
if (AccountNumbers[i] == 1001 || AccountNumbers[i] == 4382 || AccountNumbers[i] == 3020 || AccountNumbers[i] == 6245)
interest = (Balance[i] * 0.06);
else
interest = (Balance[i] * 0.03);
cout << AccountNumbers[i] << "\t\t" << Balance[i] << "\t\t" << DaysSinceDebited[i] << "\t" << interest << "\t" << endl;
}