# Thread: warning C4700 HELP

1. ## warning C4700 HELP

I am working on the program for class that im taking and its not working this is the algorithm that Im using but I dont know if im doing it right
Note: I am very new to this

Algorithm Name: UPDATE_CHECKBOOK
Problem Input(s): start_balance - the beginning checkbook balance. xact_amount - the amount of the transaction. xact_type - the type of the transaction (credit or debit). Problem Output(s): new_balance -- the ending checkbook balance. Relevant Formula(s): Adding a credit = (starting balance) + (transaction amount) Subtracting a debit = (starting balance) - (transaction amount) Algorithm:
BEGIN
Ask the user for the starting balance.
Input the starting balance (start_balance).
Ask the user for the transaction amount.
Input the amount of the transaction (xact_amount).
Ask the user for the type of transaction.
Input the type of transaction (xact_type).
If (the value of xact_type is "Credit") Then
Compute new_balance = (start_balance + xact_amount).
Else
Compute new_balance = (start_balance - xact_amount).
End If
Output the desired value (new_balance).
END

Heres what I have

float main()
{
float start_balance, xact_amount, xact_type, new_balance, credit, debit;
cout << "Please the starting balance: ";
cin >> start_balance;
cout << "Please enter the transaction amount: ";
cin >> xact_amount;
cout << "Please enter the type of transaction: ";
cin >> xact_type;
if (xact_type = credit) {new_balance = start_balance + xact_amount;}
else if (xact_type = debit) {new_balance = start_balance - xact_amount;}

return 0;
}

HELP ME! Please

2. No such thing as float mAin(). Who taught you that should be shot. Put your code around a code tag. Xact-type is better be bool, I.e 1 for credit and 0 for debit, or any way you want to define it. Then your if statement just becomes
Code:
```if( xact-type)
Do something
Else
Do something else```

3. so what would put next to main instead of float. and what do you mean by bool. Does you mean boolean and is everything else right

is this line right in my code float start_balance, xact_amount, xact_type, new_balance, credit, debit;
Sorry for all these questions but I am very new to this.. still trying to figure everything out

4. one of the two legal versions of main:
Code:
`int main()`
you don't need "credit", and "debit" becuase the value of xact_type represent them. You can use int to represent the boolean type for now.
Code:
```int xact_type;
cout << Enter 1 for credit and 0 for debit: "; << something like this would do.
cin >> xact_type;```

5. This is what I have so far
Code:
```int main()
{
int start_balance, xact_amount, xact_type, new_balance;
cout << "Please the starting balance: ";
cin >> start_balance;
cout << "Please enter the transaction amount: ";
cin >> xact_amount;
int xact_type;
cout << "Please enter 1 for credit or 0 for debit: ";
cin >> xact_type;

}```
but it's still giving me errors
error C2086: 'int xact_type' : redefinition
see declaration of 'xact_type'

6. I tagged your code, and highlighted the problem.

7. Basically it says "you are trying to define/declare something more than once." And easy fix, and Salem even pointed out where.
Simply put: once is enough.

Popular pages Recent additions