I'm just starting out and need help. I'm playing with this rough atm code and i can't figure out the error. could someone please help? I would really appreciate it. here is the code so far.
// Full Atm for practice
// William T******
#include <iostream>
using namespace std;
// start main
int main ()
{
// Declaration variable
int counter = 1;
int PIN1 = 1225;
int pin;
int answer1;
int answer2;
int answer3;
int checkingBalance = 0;
int savingsBalance = 0;
double checkingDeposit;
double checkingWithdrawl;
double savingsDeposit;
double savingsWithdrawl;
{
// start PIN processing
while (counter <= 4)
{
cout << "Please Enter Your Four(4) Digit PIN" << endl;
cin >> pin;
if (pin != PIN1)
cout << "Please Enter Your Four(4) Digit PIN" << endl;
if (pin = PIN1)
cout << "Welcome To Your Account" << endl;
counter =+ 1;
if (counter == 4)
return 0;
}
{
// start Account options
while (pin = PIN1)
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
// checking account
{
while (answer1 = 1)
cout << "Welcome to Your Checking Account." << endl;
cout << "Please Choose a Option from the List Below." << endl;
cout << "Press three(3) to Check Your Balance." << endl;
cout << "Press four(4) to Make a Deposit." << endl;
cout << "Press five(5) to make a Withdrawl." << endl;
cin >> answer2;
}
{
if (answer2 < 3)
cout << "Welcome to Your Checking Account." << endl;
cout << "Please Choose a Option from the List Below." << endl;
cout << "Press three(3) to Check Your Balance." << endl;
cout << "Press four(4) to Make a Deposit." << endl;
cout << "Press five(5) to make a Withdrawl." << endl;
cin >> answer2;
if (answer2 > 5)
cout << "Welcome to Your Checking Account." << endl;
cout << "Please Choose a Option from the List Below." << endl;
cout << "Press three(3) to Check Your Balance." << endl;
cout << "Press four(4) to Make a Deposit." << endl;
cout << "Press five(5) to make a Withdrawl." << endl;
cin >> answer2;
if (answer2 = 3)
cout << "Your Balance is:" << " " << checkingBalance << endl;
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
if (answer2 = 4)
cout << "Please Enter the Amount You Wish to Deposit." << endl;
cin >> checkingDeposit;
{
checkingBalance = checkingBalance + checkingDeposit;
}
{
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
if (answer2 = 5)
cout << "Please Enter the Amount You Wish to Withdrawl." << endl;
cin >> checkingWithdrawl;
{
if (checkingWithdrawl > checkingBalance)
cout << "You CANNOT withdrawl more money than you have." << endl;
}
{
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
{
if (checkingWithdrawl < checkingBalance)
cout << "Please Take Your Money and Have a Good Day." << endl;
}
{
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
}
// savings account
{
while (answer1 = 2)
cout << "Welcome to Your Savings Account." << endl;
cout << "Please Choose a Option from the List Below." << endl;
cout << "Press six(6) to Check Your Balance." << endl;
cout << "Press seven(7) to Make a Deposit." << endl;
cout << "Press eight(8) to make a Withdrawl." << endl;
cin >> answer3;
}
{
if (answer3 < 6)
cout << "Welcome to Your Checking Account." << endl;
cout << "Please Choose a Option from the List Below." << endl;
cout << "Press six(6) to Check Your Balance." << endl;
cout << "Press seven(7) to Make a Deposit." << endl;
cout << "Press eight(8) to make a Withdrawl." << endl;
cin >> answer3;
if (answer3 > 8)
cout << "Welcome to Your Savings Account." << endl;
cout << "Please Choose a Option from the List Below." << endl;
cout << "Press six(6) to Check Your Balance." << endl;
cout << "Press seven(7) to Make a Deposit." << endl;
cout << "Press eight(8) to make a Withdrawl." << endl;
cin >> answer3;
if (answer3 = 6)
cout << "Your Balance is:" << " " << savingsBalance << endl;
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
if (answer3 = 7)
cout << "Please Enter the Amount You Wish to Deposit." << endl;
cin >> savingsDeposit;
{
savingsBalance = savingsBalance + savingsDeposit;
}
{
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
if (answer3 = 8)
cout << "Please Enter the Amount You Wish to Withdrawl." << endl;
cin >> savingsWithdrawl;
{
if (savingsWithdrawl > savingsBalance)
cout << "You CANNOT withdrawl more money than you have." << endl;
}
{
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
{
if (savingsWithdrawl < savingsBalance)
cout << "Please Take Your Money and Have a Good Day." << endl;
}
{
cout << "Please Choose from one(1) of the Following Options." << endl;
cout << "Press one(1) to go to Checking Account Options." << endl;
cout << "Press two(2) to go to Savings Account Options." << endl;
cin >> answer1;
}
It was just a couple of basic mistakes that you made. first if all, in an if, while, do-while, etc., statement, you don't use "=". "=" sets a variable equal to a value. In a statement, you want an equality sign (==), which sees if the variable or value is equal to what is on the right. Second, you used =+ instead of +=. Lastly you just forgot a closing bracket. Based on this, i am guessing that you arent using an ide. i would suggest looking into that because it will help keep your code looking clean and tell you your mistakes if your compiler doesnt already.
Thank you both. Aramil of Elixia and Mathhead 200. I wasn't quite sure of what was wrong. I've only been learning C++ for three days now. I appreciate both of you answering the question without sarcasm most would give me. Again thank you very much. cheers.
is it working? and your welcome im not that far ahead of you and because no one would help me i got into trouble easily novices have to stick out for each other