C++ Looping through array and displaying something based on condition -


i‘m having trouble completing task, task follows: each savings account program must calculate interest paid follows: if account balance higher 10000 pounds, or account has not had money debited more 30 days, interest 6% of balance. if not, interest must 3%.

this original code:

#include <iostream> using namespace std; const int maxaccounts =8; int main() { int accountnumber[maxaccounts] = {1001, 7940, 4382, 2651, 3020, 7168, 6245,     9342}; double balance[maxaccounts] = {4254.40, 27006.25, 123.50, 85326.92, 657.0, 7423.34, 4.99, 107864.44};  int dayssincedebited[maxaccounts] = {20, 35, 2, 14, 5, 360, 1, 45}; //add code here return 0; } 

here attempt, i'm studying arrays right trying grasp it, there errors attempt. can post solution able study , learn it?

#include <iostream> using namespace std; const int maxaccounts = 8; int interest(int balance, int maxaccounts);  int main() { int accountnumber[maxaccounts] = { 1001, 7940, 4382, 2651, 3020, 7168, 6245, 9342 }; double balance[maxaccounts] = { 4254.40, 27006.25, 123.50, 85326.92, 657.0, 7423.34, 4.99, 107864.44 }; int dayssincedebited[maxaccounts] = { 20, 35, 2, 14, 5, 360, 1, 45 };   int interest(int balance, int maxaccounts) {      int total = 0;     (int = 0; < maxaccounts; i++)     {          if (balance > 10000)         {             total = balance / 100 * 1.6;             cout << accountnumber << balance << total << endl;         }         return total;      } } 

since learning, let figure out. show couple errors.

int main() { int accountnumber[maxaccounts] = { 1001, 7940, 4382, 2651, 3020, 7168, 6245, 9342 }; double balance[maxaccounts] = { 4254.40, 27006.25, 123.50, 85326.92, 657.0, 7423.34, 4.99, 107864.44 }; int dayssincedebited[maxaccounts] = { 20, 35, 2, 14, 5, 360, 1, 45 };  //you defining function inside main(). doesn't work this.  int interest(int balance, int maxaccounts) {      int total = 0;     (int = 0; < maxaccounts; i++)     {          if (balance > 10000)         {             total = balance / 100 * 1.6;             //assuming function outside main, accountnumber scope ends inside main, need pass interest function  //talking passing, passing arrays incorrectly. go tutorial http://www.tutorialspoint.com/cplusplus/cpp_passing_arrays_to_functions.htm passing arrays function             cout << accountnumber << balance << total << endl;         }         return total;      } } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -