Okay here is go this is my first time posting to this website and I hope I can get this all right for you all. I have stated this program and I gt know errors but the program will not run past my first cin cout statements? Does anyone see or can anyone help me? I am not looking for you to do my home work just want a helpful hint so I can move forward to the next chapter and add on to a awesome project that I am having fun doing.

FYI- The chapter prior to this chapter all the programs worked. This chapter we had to and "for" "while" "do-while". I believe it is the for statement but can pinpoint it. Thanks much and looking forward to your help.

// Making a bank service chapter 4

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;
using std::setprecision;
using std::fixed;
using std::transform;
using std::getline;

struct BankAccount
{
    int accountNumber;
    double balance;
    double annualRate;

};
int main()
{
    BankAccount oneAccount, twoAccount;
    double amount;
    int interestRate;
    const double ONE_ACCOUNT = 0.0;
    const double TWO_ACCOUNT = 100000;
    int x;
    double total = 0;


    int years = 10;
    int count = 1;
    const double RATE = .12;



    for(x = 0; x < .12; x++)
        cout << x << endl;
    {
    cout << "Enter account number  " ;
    cin >> oneAccount.accountNumber;
    cout << "Enter account balance  " ;
    cin >> oneAccount.balance;
    cout << "Enter account two number " ;
    cin >> twoAccount.accountNumber;
    cout << "Enter account two balance " ;
    cin >> twoAccount.balance;
    }
    if(oneAccount.accountNumber == twoAccount.accountNumber)
    cout << endl << "Enter transfer amount " << endl << 
        "from account one to account two ";
    cin >> amount;

    while(oneAccount.balance = 10)
    {
        cout << "Your account balance is $10.00  ";
    if (oneAccount.balance <= 0)
    {cout << "Insufficient funds   ";}
    if(twoAccount.balance >= TWO_ACCOUNT)
    {cout << "Your account balance will exceed the max amount of $100,000.00  ";}
    }

    cout << "Enter the amount to invest ";
    cin >> amount;
    cout << "Enter the number of years to invest from 1 to 10 years ";
    cin >> years;
    do
    {
        cout << "The goal for year " << count << " is " << amount << endl;
        amount = amount + amount * RATE;
        ++count;
    }

    while(count >= 10);

cout << "Enter interest rate ";
    cin >> interestRate;
    cout << "Account number one " << oneAccount.accountNumber <<
        " had a starting balance of $  " << oneAccount.balance << endl;
    cout << "Account number two " << twoAccount.accountNumber <<
        " had a starting balance of $  " << twoAccount.balance << endl;

    cout << "Account number one " << oneAccount.accountNumber << 
        " has an ending amount of $ " << (oneAccount.balance -= amount) << endl;
    cout << "Account number two " << twoAccount.accountNumber <<
        " has an ending amount of $ " << (twoAccount.balance += amount) << endl;




    system("pause");
    return 0;
}   //end of main function

This line

while(oneAccount.balance = 10)

Do you really want to assign 10 to oneAccount.balance?

This line

while(oneAccount.balance = 10)

Do you really want to assign 10 to oneAccount.balance?

Thanks that was stupid but I guess after looking at it for 2 days and being mad I needed some fresh eyes. Thanks again.

Please post properly format code like below

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;
using std::setprecision;
using std::fixed;
using std::transform;
using std::getline;

struct BankAccount
{
	int accountNumber;
	double balance;
	double annualRate;
};

int main()
{
	BankAccount oneAccount, twoAccount;
	double amount;
	int interestRate;
	const double ONE_ACCOUNT = 0.0;
	const double TWO_ACCOUNT = 100000;
	int x;
	double total = 0;


	int years = 10;
	int count = 1;
	const double RATE = .12;



	for(x = 0; x < .12; x++)
		cout << x << endl;

	{
		cout << "Enter account number " ;
		cin >> oneAccount.accountNumber;
		cout << "Enter account balance " ;
		cin >> oneAccount.balance;
		cout << "Enter account two number " ;
		cin >> twoAccount.accountNumber;
		cout << "Enter account two balance " ;
		cin >> twoAccount.balance;
	}

	if(oneAccount.accountNumber == twoAccount.accountNumber)
		cout << endl << "Enter transfer amount " << endl << "from account one to account two ";

	cin >> amount;

	while(oneAccount.balance == 10)
	{
		cout << "Your account balance is $10.00 ";
		if (oneAccount.balance <= 0)
		{
			cout << "Insufficient funds ";
		}
	
		if(twoAccount.balance >= TWO_ACCOUNT)
		{
			cout << "Your account balance will exceed the max amount of $100,000.00 ";
		}
	}

	cout << "Enter the amount to invest ";
	cin >> amount;
	cout << "Enter the number of years to invest from 1 to 10 years ";
	cin >> years;

	do
	{
		cout << "The goal for year " << count << " is " << amount << endl;
		amount = amount + amount * RATE;
		++count;
	}
	while(count >= 10);

	cout << "Enter interest rate ";
	cin >> interestRate;
	cout << "Account number one " << oneAccount.accountNumber <<
	" had a starting balance of $ " << oneAccount.balance << endl;
	cout << "Account number two " << twoAccount.accountNumber <<
	" had a starting balance of $ " << twoAccount.balance << endl;

	cout << "Account number one " << oneAccount.accountNumber <<
	" has an ending amount of $ " << (oneAccount.balance -= amount) << endl;
	cout << "Account number two " << twoAccount.accountNumber <<
	" has an ending amount of $ " << (twoAccount.balance += amount) << endl;


	return 0;
} //end of main function

On line 37, in the above code, is that really how you want your for statement?

Please post properly format code like below

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;
using std::setprecision;
using std::fixed;
using std::transform;
using std::getline;

struct BankAccount
{
	int accountNumber;
	double balance;
	double annualRate;
};

int main()
{
	BankAccount oneAccount, twoAccount;
	double amount;
	int interestRate;
	const double ONE_ACCOUNT = 0.0;
	const double TWO_ACCOUNT = 100000;
	int x;
	double total = 0;


	int years = 10;
	int count = 1;
	const double RATE = .12;



	for(x = 0; x < .12; x++)
		cout << x << endl;

	{
		cout << "Enter account number " ;
		cin >> oneAccount.accountNumber;
		cout << "Enter account balance " ;
		cin >> oneAccount.balance;
		cout << "Enter account two number " ;
		cin >> twoAccount.accountNumber;
		cout << "Enter account two balance " ;
		cin >> twoAccount.balance;
	}

	if(oneAccount.accountNumber == twoAccount.accountNumber)
		cout << endl << "Enter transfer amount " << endl << "from account one to account two ";

	cin >> amount;

	while(oneAccount.balance == 10)
	{
		cout << "Your account balance is $10.00 ";
		if (oneAccount.balance <= 0)
		{
			cout << "Insufficient funds ";
		}
	
		if(twoAccount.balance >= TWO_ACCOUNT)
		{
			cout << "Your account balance will exceed the max amount of $100,000.00 ";
		}
	}

	cout << "Enter the amount to invest ";
	cin >> amount;
	cout << "Enter the number of years to invest from 1 to 10 years ";
	cin >> years;

	do
	{
		cout << "The goal for year " << count << " is " << amount << endl;
		amount = amount + amount * RATE;
		++count;
	}
	while(count >= 10);

	cout << "Enter interest rate ";
	cin >> interestRate;
	cout << "Account number one " << oneAccount.accountNumber <<
	" had a starting balance of $ " << oneAccount.balance << endl;
	cout << "Account number two " << twoAccount.accountNumber <<
	" had a starting balance of $ " << twoAccount.balance << endl;

	cout << "Account number one " << oneAccount.accountNumber <<
	" has an ending amount of $ " << (oneAccount.balance -= amount) << endl;
	cout << "Account number two " << twoAccount.accountNumber <<
	" has an ending amount of $ " << (twoAccount.balance += amount) << endl;


	return 0;
} //end of main function

On line 37, in the above code, is that really how you want your for statement?

I changed line 37 after changing while(oneAccount.balance == 10)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.