Solve 7 errors

Why are their 7 errors? (VS2008)

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
boolean continue=true;
double balance;
double input;
totalWithdrawals;
totalDeposits;


while (continue)
{
	cout<<"Enter current balance on this account: ";
	cin>> balance;
	cout<<"Enter withdrawal or deposit amount: "
	cin>>input;
	if (input < 0)


{
	totalWithdrawals++;
}
	else if (input > 0)
{
	totalDeposits++;
}
	balance+=input;
	cout<<"Your balance is " + balance<<endl;
	cout<<"Total deposits: " + totalDeposits<<endl;
	cout<<"Total withdrawals: " + totalWithdrawals<<endl;
	cout<<"Press 0 to quit, any other key to continue"
	cin>>continue;
}
continue is a C++ keyword can't use it as a variable or a test condition. line 12 and 28 missing semi columns
Last edited on
1
2
3
	cout<<"Your balance is " + balance<<endl;
	cout<<"Total deposits: " + totalDeposits<<endl;
	cout<<"Total withdrawals: " + totalWithdrawals<<endl;


has to be cout<<"Your balance is " << balance <<endl;
Still dosn't work
what have you changed , post you're code.
are these variables declared anywhere ?
1
2
3
totalWithdrawals;
totalDeposits;
what is the code missing that will make it work?

This is exactly what I have:

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
boolean continue=true;
double balance;
double input;
totalWithdrawals;
totalDeposits;


while (continue)
{
	cout<<"Enter current balance on this account: ";
	cin>> balance;
	cout<<"Enter withdrawal or deposit amount: ";
	cin>>input;
	if (input < 0)


{
	totalWithdrawals++;
}
	else if (input > 0)
{
	totalDeposits++;
}
	balance+=input;
	cout<<"Your balance is " << balance<<endl;
	cout<<"Total deposits: " << totalDeposits<<endl;
	cout<<"Total withdrawals: " << totalWithdrawals<<endl;
	cout<<"Press 0 to quit, any other key to continue";
	cin>>continue;
}
Is this code inside some function ? Also you didnt make changes that i told you about.
What should I change continue to then?

No this is code in and of itself.

Im not sure what changes you mean
i dont know what the requirements of this program , but theres a lot whats wrong with it.
heres what im supposed to do:

Here are the specifications:

Globals and I/O cannot be used.

Calculating Checkbook Balances

Write a program that calculates the closing balance for an indeterminate number of checkbooks. The program must logically flow as follows:

Firstly) You must Ask for data for the first checkbook- opening balance, withdrawals and deposits

Secondly) Display the opening balance, the number of withdrawals, the number of deposits and the closing balance

lastly) Ask the user if he wishes to calculate the balance on another checkbook:
If the input says yes, go back to Step 1 and perform the rest of the steps.

If not end the program

All data must be standard input. The format is a series of numbers, the first of which is the opening balance. Thereafter, the user will enter withdrawals as negative numbers and deposits as positive numbers. Input will indicate the finish of the monetary data by inputting zero. The user will enter a lower case 'y' to select the option of balancing another checkbook; otherwise, the user will enter a lower case 'n'.


Thank you I need this for my high school class
Last edited on
We're not going to do your assignment for you.

As for the code you posted, I think you're getting other programming languages mixed up with C++

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
#include <iostream>
#define CONT true // preprocessor macro.
using namespace std;

int main(){
	double balance,input,totalWithdrawals,totalDeposits;
	// I'm assuming totalWithdrawals and totalDeposits are not functions, but values.
	
	do {
		cout << "\nEnter the current balance on the account: ";
		cin >> balance;
		cout << "\nEnter withdrawal or deposit amount: ";
		cout << "\nEnter 0 to end program"
		cin >> input;
		switch(input)
			case (input < 0):
				totalWithdrawals++;
				break;
			case (input > 0)
				totalDeposits++;
				break;
			default:
				return 0;
				break;
		}
		balance += input;
		cout << "Balance = "<< balance << endl;
		cout << "Deposit count = " << totalDeposits << endl;
		cout << "Withdrawal count = " << totalWithdrawals << endl;
	} while (CONT == true);
}


EDIT: forgot the code blocks. This may or may not be within the constraints, then again, I don't really care. If it isn't, it's up to you to make it fit said constraints.
Last edited on
Topic archived. No new replies allowed.