Question
C++ Read and do as instructed on please
(C++Program *** use only condition statements, loops, functions, files, and arrays. Do NOT use material such as classes. Make
(C++ Program) se only condition statements, loops, functions, files, and arrays. Do NOT use material such as classes Make sur
(C++Program *** use only condition statements, loops, functions, files, and arrays. Do NOT use material such as classes. Make sure to add comments** You are to write an ATM Program. The ATM should allow the user to do the following: 1. Create account 2. Log in 3. Exit When they press 1, they are asked for first name (capital first letter). Then it should ask for password. The computer should give the user a random 4 digit account number (cant start with a 0). Make sure you follow these rules: The user name should not be the same as another user's name. The account number should not be the same as the other user's account number. L The new account should start off with 50 dollars. -The accounts (including name, password and account number) should be on a file called Accounts. *use arrays to hold everyones information from the file, use a function to retrieve this data, which is done at the start of the program When you press 2, they are prompted to enter name, and password. You should have already received all information from the Accounts file as mentioned above. If they enter the wrong information 3 times, exit back to the previous window with the 3 choices. If they enter correctly, should do the followint: Withdraw take money, if there is not enough money it should warn them and allow them to try again OR press-1 to return to previous window. Any other negative number should not work. --Deposit add money, if they do not want to add money, -1 will return to previous window while any other negative number will not work .-View Balance - display balance and have user press enter to return to previous window. Exit exit the account and return back to the original screen with the 3 options. When this option is selected, it should update the Accounts file with the new information. -Any other number will not work When they press 3, thank them and exit program.
(C++ Program) se only condition statements, loops, functions, files, and arrays. Do NOT use material such as classes Make sure to add comments* You are to write an ATM Program. The ATM should allow the user to do the following: 1. Create account 2. Log in 3. Exit When they press 1, they are asked for first name (capital first letter). Then it should ask for password. The computer should give the user a these rules: random 4 digit account number (cant start with a 0). Make sure you follow --The user name should not be the same as another user's name. The account number should not be the same as the other user's account number. -The new account should start off with 50 dollars. --The accounts (including name, password and account number) should be on a file called Accounts. use arrays to hold everyones information from the file, use a function to retrieve this data, which is done at the start of the program* When you press 2, they are prompted to enter name, and password. You should have already received all information from the Accounts file as mentioned above. If they enter the wrong information 3 times, exit previous window with the 3 choices. If they enter correctly, should do the followint: back to Withdraw take money, if there is not enough money it should warn them and allow them to try again OR press-1 to return to previous window. Any other negative number should not work. Deposit- add money, if they do not want to add money, -1 will return to previous window while any other negative number will not work View Balance-display balance and have user press enter to return to previous window. Exit- exit the account and return back to the original screen with the 3 options. When this option is selected, it should update the Accounts file with the new information. --Any other number will not work When they press 3, thank them and exit program.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ans........................................................................................................................

#include<iostream>

#include<fstream>

#include<cstdlib>

using namespace std;

void display_options()

{

printf("\n1. Create account \n");

printf("2. Log in \n");

printf("3. Exit \n\n");

printf("Please enter : ");

}

void display_T()

{

printf("\n1. Withdraw\n");

printf("2. Deposite \n");

printf("3. View balance ");

printf("4. Exit\n\n : ");

printf("Please Enter : ");

}

struct account

{

int accountnumber;

string name;

string password;

int balance;

};

account A[1000];

int n=0;

int generateaccountnumber()

{

int r;

while(true)

{

r=rand()%10000;

bool flag=false;

for(int i=0 ;i<n; i++)

{

if(A[i].accountnumber==r)

{

flag=true;

break;

}

}

if(flag==false)

return r;

}

}

int checkaccount(int number,string password)

{

for(int i=0; i<n; i++)

{

if(A[i].accountnumber==number && A[i].password==password)

return i;

}

return -1;

}

int main()

{

char option;

int num_acc=0;

ifstream infile("Vishal_bank.txt");

if (!infile.is_open())

{

cout<<"Error to open file.";

return 0;

}

int number;

string name;

string password;

int balance;

while (infile >> number >> name >> password>>balance)

{

A[n].accountnumber=number;

A[n].name=name;

A[n].password=password;

A[n].balance=balance;

n=n+1;

}

infile.close();

while(1)

{

printf("\n**** Welcome to Bank Application ****\n");

display_options();

cin>>option;

printf("%c \n", option);

int temp;

switch(option)

{

case '1': number=generateaccountnumber();

cout<<"enter name: ";

cin>>name;

cout<<"enter password: ";

cin>>password;

A[n].accountnumber=number;

A[n].name=name;

A[n].password=password;

A[n].balance=50;

cout<<"your new account number is :" <<number<<endl;

n=n+1;

break;

case '2': cout<<"enter account number: ";

cin>>number;

cout<<"enter password: ";

cin>>password;

temp=checkaccount(number,password);

if(temp!=-1)

{

while(true)

{

display_T();

cin>>option;

int money;

switch(option)

{

case '1':cout<<"Enter money : ";

cin>>money;

if(money==-1)

break;

else

while(money<-1)

{

cout<<"Enter valid money."<<endl;

cin>>money;

}

if(A[temp].balance-money<0)

cout<<"can't withdrawl"<<endl;

else

A[temp].balance=A[temp].balance-money;

break;

case'2':

cout<<"Enter money : ";

cin>>money;

if(money==-1)

break;

else

while(money<-1)

{

cout<<"Enter valid money."<<endl;

cin>>money;

}

A[temp].balance=A[temp].balance+money;

break;

case 3:

cout<<"Balance"<<A[temp].balance<<endl;

break;

case 4:

break;

default:

cout<<"Wrong choice";

}

}

}

else

{

cout<<"Wrong details"<<endl;

}

break;

case '3': exit(0);

break;

default : system("cls");

printf("Please enter one of the options");

printf("(1/2/3) to continue \n ");

break;

}

}

return 0;

}

Add a comment
Know the answer?
Add Answer to:
C++ Read and do as instructed on please (C++Program *** use only condition statements, loops, functions,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST...

    In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST use GUI, that means all user input must be through the windows. The "first window" is the window on the top left of the following picture. Add 5 more items to be purchased. Search is accessed from second window, top right. Thw third window is the bottom left, and the fourth window is the bottom right. The program MUST CONTAIN EVERYTHING IN THE PICTURES....

  • Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc....

    Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc. needs a program in which the date and temperature in Celsius degrees of an industry laboratory are recorded and stored in a sequential file. In addition, you can see the recorded data and convert the temperatures in the following units: Fahrenheit, Kelvin and Rankine. In addition, they want to see a linear graph that reflects how the temperature has fluctuated day by day, for...

  • I have to use java programs using netbeans. this course is introduction to java programming so...

    I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...

  • Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user...

    Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...

  • Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only....

    Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only. Thank you. Pointers and Dynamic Memory – Chapter 11 1. Write code using pointers and the Accounts class from week 1 assignment as follows – create a program in which you a. Create 10 accounts using an array with id’s 0 to 9 and refer to each account using pointer notation b. Add an initial balance of...

  • Please do this in C++ using only for loops, while loops, and do while loops. No...

    Please do this in C++ using only for loops, while loops, and do while loops. No arrays. Use for loop, while loop, and do while loops to generate a table of decimal numbers, as well as the binary, octal, and hexadecimal equivalents of the decimal numbers in the range 1-256 Note: See Appendix for number systems The program should print the results to the Console without using any string formats Design Details: The Main program should prompt the user for...

  • In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops...

    In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops for the input validations required: number of employees(cannot be less than 1) and number of days any employee missed(cannot be a negative number, 0 is valid.) Each function needs a separate flowchart. The function charts are not connected to main with flowlines. main will have the usual start and end symbols. The other three functions should indicate the parameters, if any, in start; and...

  • Please, please help with C program. This is a longer program, so take your time. But...

    Please, please help with C program. This is a longer program, so take your time. But please make sure it meets all the requirements and runs. Here is the assignment: I appreciate any help given. Cannot use goto or system(3) function unless directed to. In this exercise you are to create a database of dogs in a file, using open, close(), read, write(), and Iseek(). Do NOT use the standard library fopen() ... calls! Be sure to follow the directions!...

  • InventoryManagement

    Problem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes re-ordering the menu items and making changes to the description of a menu item without having to change the code.Security:The company has...

  • Please help me the JAVA program - Choose Your Operation Write a program that uses a...

    Please help me the JAVA program - Choose Your Operation Write a program that uses a WidgetView object to do the following: Generate two random integers between 1 and 9 (inclusive). Name one of them x, the other y. Display them to the user using JLabel objects. Create a JLabel object displaying the text "Enter an operation number." Create a JTextField for the user's input. Create a JButton displaying the text "Press here when you've entered your operation." Use addAndWait...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT