Question

In: Computer Science

Using Repl.it In this assignment you will create a Java program that allows a Bank customer...

Using Repl.it

In this assignment you will create a Java program that allows a Bank customer to do the following:

1) Create a bank account by supplying a user id and password

.2) Login using their id and password

3) Quit the program.

Now if login was successful the user will be able to do the following:

1) Withdraw money.

2) Deposit money.

3) Request balance.

4) Quit the program.

If login was not successful (for example the id or password did not match) then the user will be taken back to the introduction menu.

This is what your program in action will look like:

Hello

Welcome to Genesis Bank ATM Machine

Please select an option from the menu below:

l -> Login

c -> Create New Account

q -> Quit

> L

Please enter your user id: 12

Please enter your password: 2345

Create an Array List of about 10 Bank customers, basic money transactions for deposit, withdrawal, and balance checking.

Solutions

Expert Solution

package bankapplication;
import java.util.*;

/**
*
* @author mmc
*/
class Account
{
  
public Account(int anAccountNumber)
{   
accountNo = anAccountNumber;
amtbal = 0;
}

public Account(int anAccountNo, double intBalance,String uname,String pword)
{   
accountNo = anAccountNo;
amtbal = intBalance;
username=uname;
password=pword;
}
  
public int getAccountNumber()
{   
return accountNo;
}

public void deposit(double amount)
{
double newBal = amtbal + amount;
amtbal = newBal;
}
public void withdraw(double amount)
{   
double newBalance = amtbal - amount;
amtbal = newBalance;
}
  
public double getBal()
{   
return amtbal;
}

boolean checkUserName(String uname,String pword,ArrayList<Account> al)
{
boolean c=true;
for(int i=0;i<10;i++)
{
Account d=al.get(i);

if(d.username==uname && d.password==pword)
c=true;
else
c=false;
}
return c;
}

private int accountNo;
private double amtbal;
private String username,password;
int n=10;
}

public class BankApplication
{   
static int account;
public static void main(String[] args)
{

Scanner s=new Scanner(System.in);
ArrayList<Account> accounts = new ArrayList<Account>();
String uname,pword;
int i;
account=1000;
do
{
System.out.println("Please select from the option");
System.out.println("1.Create Bank account");
System.out.println("2.LOGIN");
System.out.println("3.Exit");
i=s.nextInt();

switch(i)
{
case 1:

System.out.println("Enter username:");
uname=s.nextLine();
System.out.println("Enter password:");
pword=s.nextLine();
i++;
accounts.add(new Account(i,0,uname,pword));   
break;

case 2:
boolean check;
System.out.println("Enter UserName");
uname=s.nextLine();
System.out.println("Enter password:");
pword=s.nextLine();
check=accounts.checkUserName(uname,pword,accounts);
if(check==true)
{
int j=0;
do
{
System.out.println("1.Withdraw Money");
System.out.println("2.Deposite MOney");
System.out.println("3.Request Balance");
System.out.println("3.Exit");

System.out.println("Select a option:");
switch(j)
{
case 1:
System.out.println("Enter Amount:");
double am=s.nextInt();
accounts.withdraw(am);
}
}
while(j==3);
break;
}
default:
System.out.println("Select an option");
}
}
while(i==3);

}
}


Related Solutions

Create a java program that allows people to buy tickets to a concert. Using java create...
Create a java program that allows people to buy tickets to a concert. Using java create a program that asks for the users name, and if they want an adult or teen ticket. As long as the user wants to purchase a ticket the program with "yes" the program will continue. When the user inputs "no" the program will output the customer name, total amount of tickets, and the total price. The adult ticket is $60 and the child ticket...
Write a Java program to process the information for a bank customer.  Create a class to manage...
Write a Java program to process the information for a bank customer.  Create a class to manage an account, include the necessary data members and methods as necessary.  Develop a tester class to create an object and test all methods and print the info for 1 customer.  Your program must be able to read a record from keyboard, calculate the bonus and print the details to the monitor.  Bonus is 2% per year of deposit, if the amount is on deposit for 5 years...
JAVA PROGRAM Overview : You will create a card deck program that allows the player to...
JAVA PROGRAM Overview : You will create a card deck program that allows the player to shuffle a deck of cards and play a game that draws and plays cards until all cards in the deck have been used. Instructions: The application must be able to perform the following tasks : 1. At the start of a new game, it shuffles all cards using a deck shuffler 2. The player then draws X number of cards from the deck and...
In this assignment, you will create a Java program to search recursively for a file in...
In this assignment, you will create a Java program to search recursively for a file in a directory. • The program must take two command line parameters. First parameter is the folder to search for. The second parameter is the filename to look for, which may only be a partial name. • If incorrect number of parameters are given, your program should print an error message and show the correct format. • Your program must search recursively in the given...
Description: The purpose of the program is to create a Java ticket purchasing program that allows...
Description: The purpose of the program is to create a Java ticket purchasing program that allows for users to log in, purchase tickets, keep records of tickets purchased, and keep information about the user. Program Requirements: The following are the program requirements: Must be fully functioning including registration, log-in, view events, and purchase tickets Tickets should be purchased using “points”, no information should be provided via the user for payment method. Default each user to an allotted number of points...
This Python assignment will involve implementing a ​bank program that manages bank accounts​ and allows for...
This Python assignment will involve implementing a ​bank program that manages bank accounts​ and allows for deposits, withdrawals, and purchases. USE THE PREASSIGNED CODE BELOW: The program will initially load a list of accounts from a .txt file, and deposits and withdrawals from additional .csv files. Then it will parse and combine all of the data and store it in a dictionary. Steps Complete the required functions Implement all of the functions defined in the ​bank_accounts.py Docstrings have already been...
Java program In this assignment you are required to create a text parser in Java/C++. Given...
Java program In this assignment you are required to create a text parser in Java/C++. Given a input text file you need to parse it and answer a set of frequency related questions. Technical Requirement of Solution: You are required to do this ab initio (bare-bones from scratch). This means, your solution cannot use any library methods in Java except the ones listed below (or equivalent library functions in C++). String.split() and other String operations can be used wherever required....
COP 2800, Java Programming Assignment 6-1 Using Java create a program using the “Methods” we covered...
COP 2800, Java Programming Assignment 6-1 Using Java create a program using the “Methods” we covered this week. come up with a “problem scenario” for which you can create a “solution”. Utilize any/all of the examples from the book and class that we discussed. Your program should be interactive and you should give a detailed statement about what the “description of the program – purpose and how to use it”. You should also use a “good bye” message. Remember to...
For this assignment you will write a Java program using a loop that will play a...
For this assignment you will write a Java program using a loop that will play a simple Guess The Number game. Create a new project named GuessANumber and create a new Java class in that project named GuessANumber.java for this assignment. The program will randomly generate an integer between 1 and 200 (including both 1 and 200 as possible choices) and will enter a loop where it will prompt the user for a guess. If the user has guessed the...
(JAVA) Create a program that creates a mini database of numbers that allows the user to:...
(JAVA) Create a program that creates a mini database of numbers that allows the user to: reset the database, print the database, add a number to the database, find the sum of the elements in the database, or quit. In main, you will declare an array of 10 integers (this is a requirement). Then you will define the following methods: • printArray (int[ ] arr) – this takes in an array and prints it • initArray (int[ ] arr) –...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT