Question

In: Computer Science

writing a program that will act like an ATM machine by the end of this course....

writing a program that will act like an ATM machine by the end of this course. In order to access the ATM, the customer must enter their user name and their passcode. After 3 incorrect attempts at entering the user name and password, the program will end. The list of legitimate users along with their user ID, passcode and account balance will be provided to you.

There are only 5 functions that can be carried out by the ATM:

1 – Deposit (adding money to the account)

2 – Withdrawal (removing money from the account)

3 – Balance Inquiry (check current balance)

4 – Transfer Balance (transfer balance from one account to another)

5 – Log Out (exits/ends the program)

Allow the user to make up to a maximum of 3 transactions at a time. After 3 transactions, the program will terminate. Each transaction cannot exceed $500; for example, a user cannot withdraw more than $500.00, if there is $500.00 available on their account. After a transaction is completed, the program will update the running balance and give the customer a detailed description of the transaction. A customer cannot overdraft on their account; if they try to withdraw more money than there is, a warning will be given to the customer. Also note that the ATM doesn’t distribute or collect coins – all monetary values are in whole dollars (e.g. an integer is an acceptable variable type). Any incorrect transaction types will display an appropriate message and count as a transaction.

Solutions

Expert Solution

The sample program is self explanatory, and with all the functions being listed as shown above.

And the sample program can be extended to allow three chances for authentication, and for all with addition of a simple for loop.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
class custaccount
{
public:
string name;
long passcode;
double accountno;
custaccount()
{
cout<<"Enter number:";
cin>>name;
cout<<"Enter Passcode:";
cin>>passcode;
cout<<"Enter accountno;";
cin>>accountno;
}
bool authenticate(string custname,int pass_code)
{
string custname;
long passcode;
int i=0;
cout<<"Enter Name:";
cin>>custname;

for(i=0;i<=20;i++)
{
cout<<"Enter passcode:";
cin>>pass_code;

int flag=0,j=0;

for(j-0;j<=20;j++)
{
if(pass_code==passcode)
{
flag=1;
}
else
{
flag-=0;
}
}
if(flag==1)
{
int i=0,j=0;

for(j=0;j<=20;j++)
{
if (cust_name=name[i])
{
flag1=1;
exit(0);
}

else
{
flag1==0;
exit(0);
}
}
flag1=0;
}
else
{
flag1==0;
}
return flag1;
}
}
};

void deposit(long amt,long accountno,string custname)
{
accontq1=accountno;
custnam=custname;
if(authenticate(accontq1,custname))
{
long depositsum;
cout<<"Enter amount you want to deposit:";cin>>depositsum;
accountsum+=depositsum;
return 0;
}

void withdrawl(long amt, long accountno, string custname)
{
accontq1=accountno;
custnam=custname;
If(authenticate(account1,custnam))
{ long withdrawlsum;
cout<<"Enter amount you want to deposit:";cin>>withdrawlsum;
accountsum-=withdrawlsum;
}
else
{
Return 0;
}
}
void balanceenquiry(long accountno)
{
custaccount a1;
int flag=0;
int I;
for(i=0;i<=20;i++)
{
if a1[i].account_no==accountno)
{
cout<<"Balance=";<<a[i].accountsum;
flag=1;
}
else
{
flag=0;
}
}
if(flag==0)
{
cout<<"account invalid:";
}
}
}
}
void transferbalance(long sendac, long recac, double accsum)
{
custaccount a1;
a1[sendac].accountsum-accsum;
a1[reccac].accountsum+=accsum;
return 0;
}
int main()
{
int accountno, passcode;
Cout<<"Enter accountno"; cin>>accountno;
cout<<"Enter passcode"; cin>>passcode;
If(authenticate(accountno,passcode)
{ int choice;
cout<<"Enter your choice 1. Withdrawl 2. Deposit 3. Balance enquiry 4. Long out:"; cin>> choice;
switch(choice)
{
case'1': custaccount[accountno].withdrawl(amt);
break();
case'2': custaccount[accountno].deposit(amt);
break();
case'3':custaccount[accountno].balanceenquiry(accountno);
break();
case'4': cout<<"You are logged out:";exit(0);
}
}
else
{
cout<<"Invalid AccountNo."; exit(0);
}
return 0;
}


Related Solutions

ACT Prep Course. ACT prep courses like to market that you can increase your ACT score...
ACT Prep Course. ACT prep courses like to market that you can increase your ACT score by taking their courses. Some statisticians were curious how effective these courses really were. They decided to investigate the truth of the claim by measuring the average score increase for a random sample of students selected to take an ACT prep course. These students took the ACT twice, once before and once after taking the course. The variable of interest was the increase in...
Your final project will satisfy the following scenario: You are writing a program that will act...
Your final project will satisfy the following scenario: You are writing a program that will act as an ATM machine by the end of this course. In order to access the ATM, the customer must enter their user name and their passcode. After 3 incorrect attempts at entering the user name and password, the program will end. The list of legitimate users along with their user ID, passcode, and account balance will be provided to you. There are only 5...
Using a (GUI interface), write a Java program that simulates an ATM machine with the following...
Using a (GUI interface), write a Java program that simulates an ATM machine with the following options menu: "Welcome" 1. Deposit to account 2. Withdraw 3. Exit
I have an ATM Machine program. I'm not sure where to place the:   public void io() {...
I have an ATM Machine program. I'm not sure where to place the:   public void io() { section so the program gives the following output: Welcome to ATM Press Enter to begin; Enter amount to begin: Enter amount to withdraw: 230 Cash dispensed as follows: $100 Bills: 2 $20 Bills: 1 $10 Bills: 1 The progam consists of Main.java class Main { public static void main(String[] args) { ATM atm = new ATM(); atm.init(); atm.run(); System.out.println(); System.out.println("ATM Version 0.1.0"); System.out.println("Copyright (C)...
Last week, Canada announced that they would launch a pilot program that would set up ATM-like...
Last week, Canada announced that they would launch a pilot program that would set up ATM-like vending machines to dispense hydromorphone to those who are addicted to opioids. Many see this intervention as a novel and potentially unconventional way to address the problems with opioid abuse. Please read the article here before responding. I would like to know your thoughts on this approach. What are the risks and benefits? Do you believe that this approach will be effective?
CASE Study: A Report on Global ATM Frauds The Automatic Teller Machine (ATM) was first commercially...
CASE Study: A Report on Global ATM Frauds The Automatic Teller Machine (ATM) was first commercially introduced in the 1960s. By 2005, there were over 1.5 million ATMs installed worldwide. The introduction of the ATM proved to be an important technological development that enabled financial institutions to provide services to their customers in a 24X7 environment. The ATM has enhanced the convenience of customers by enabling them to access their cash wherever required from the nearest ATM. However, as the...
writing an agument supporting or discourage the act of freewriting with Elbow cite
writing an agument supporting or discourage the act of freewriting with Elbow cite
I'm writing an essay for an Economics course. The essay is premised on the impact that...
I'm writing an essay for an Economics course. The essay is premised on the impact that the COVID-19 pandemic has had on labor demand. Could you explain this impact? Could you make a graph or two visualizing this impact?
Are strategic plans an act of futility, or a real tool? Can government act like a...
Are strategic plans an act of futility, or a real tool? Can government act like a business? Who decides on the vision or direction of the community?
write a report about travel agency in c++ not a program writing just report writing
write a report about travel agency in c++ not a program writing just report writing
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT