Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4077026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:29:57+00:00 2026-05-20T17:29:57+00:00

I need to be able to have the objects within the array be valid

  • 0

I need to be able to have the objects within the array be valid or invalid/ have value or have no value.

So if the user entered only 5 accounts out of 10 possible, it would throw away the last 5 that do not have any value what so ever, so as to not ask for a computed interest for an account that doesn’t exist.

How do I do this?

#include <iostream>
#include <iomanip>

using namespace std;

class BankAccount
{
private:
int accountNum;
double accountBal;
static const double annualIntRate;
public:
void enterAccountData(int, double);
void computeInterest();
void displayAccount();
};
//implementation section:
const double BankAccount::annualIntRate = 0.03;
void BankAccount::enterAccountData(int number, double balance)
{
cout << setprecision(2) << fixed;



cout << "Enter the account number " << endl;
cin >> number;
accountNum = number;
while(number < 0 || number < 1000)
{
    cout << "Account numbers cannot be negative or less than 1000 " <<
        "Enter a new account number: " << endl;
    cin >> number;
}

cout << "Enter the account balance " << endl;
cin >> balance;
accountBal = balance;
while(balance < 0)
{
    cout << "Account balances cannot be negative. " <<
        "Enter a new account balance: " << endl;
    cin >> balance;
}
return;
}
void BankAccount::computeInterest()
{
const int MAX_ACCOUNTS = 10;
const int MONTHS_IN_YEAR = 12;
int months;
double rate = 0; 
int counter = 0;

cout << endl << "How many months will the account be held for? " << endl;
cin >> months;
counter = 0;
do
{
 accountBal = accountBal * annualIntRate + accountBal;
 counter++;
}while(months > counter);

cout << endl << "Account # " << accountNum << " 's balance is:$" << accountBal << endl;
}

int main()
{
const int QUIT = 0;
const int MAX_ACCOUNTS = 10;
int counter;
int input;
int number = 0;
double balance = 0;

BankAccount accounts[MAX_ACCOUNTS];
//BankAccount display;

counter = 0;

do
{
    accounts[counter].enterAccountData(number, balance);
    cout << " Enter " << QUIT << " to stop, or press 1 to proceed.";
    cin >> input;
    counter++;

}while(input != QUIT && counter != 10);

for(counter = 0; counter < MAX_ACCOUNTS; counter++)
{
    accounts[counter].computeInterest();
}
system("pause");
return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:29:58+00:00Added an answer on May 20, 2026 at 5:29 pm

    You should try tonarrow down your questions to just what you are really asking, this is a little confusing to look at.

    After the first loop, have it “remember” what value for counter it managed to reach, and then in the second loop only iterate up to that, instead of up to MAX_ACCOUNTS.

    And converting from months to years is just dividing by 12 no?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to have a SelectionBoxItemTemplate for my ComboBox, but am
I need to be able to have an SQL query that searches my database
In the ASP.Net application I am writing I need to be able to have
Consider this page @ http://www.bloodbone.ws/screwed.html I need to be able to have the a.grow
I have this script and need to be able to call the $play variable
I need to be able to manually trigger a mouse click and have that
I need to be able to display data that I have in 15 minute
I have many PowerPoint presentations that I need to be able to add to
I have a program that I need to be able to search a file
I have a class that I need to be able to serialize to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.