Question

This assignment must be completed on your own with your team mates. Dont give your code to others or use other students code. This is considered academic m will result 0 marks) Write a java program that mange JUC Bank accounts services. The program should have the following: The total number of accounts (n) will be specified by the user at the beginning of the program. Depending upon the entered number, create three Arrays as following o o o Array to store customer names Array to store Account ID and Account number Array to store Balance * Account ID and Account number should be assign automatically when an account created (sample for 100 accounts) Balance cannot be a negative value Account ID Account number 180000 720000 180001 180002 720002 Name Balance 80000 2 8900.0 Abdullah Ahmed 72000 Lama Abdullatif 180099720099 1025.36 Display the following services to the user o Create new account o Account Details o Deposit o Withdraw o Display all accounts details Ask the user to choose the service they want to perform < To create new account the user will enter the customer name and his her balance e To view account details You have to ask the user to enter the account ID only Check if the account has been created the view the details o o Deposition should be a positive value and the balance should be updated Update the balance after withdraw (balance cannot be negative Display all accounts: display all the information (Customers name, Account ID Account Number, Account Balance) * * Ask the user if he/she would like to perform another service Write comments to show how the program works
The final output should look something like this (Note: that the names and balance of accounts can be different depending on the users input. Welcome to JUC Bank Please enter the number of accounts you would like to manage 5 Select a service from the following list 1- Create new account 2- Account Details 3- Deposit - Withdraw 5- Display all accounts details Your selection> 2 No account has been created yet Do you want to do another service [y-yes l n-NO]: y Select a service from the following list 1-Create new account 2- Account Details 3- Deposit 4- Withdraw 5- Display all accounts details Your selection> 1
Customer name: Mona Alluwaym Balance: 800.2 Do you want to do another service ly- yes l n-M): y Select a service from the following list 1- Create new account 2- Account Details 3- Deposit 4-Withdraw 5- Display all accounts details Your selection >>> 1 Customer name: Ahmed Abdullah Balance: 90365. 25 Do you want to do another service [y- yes n NO]: Y Select a service from the following list 1- Create new account 2- Account Details 3- Deposit 4-Withdraw 5- Display all accounts details Your selection >> 5 All Account Details Account holder: Mona Alluwaym Account ID: 72000 Account number: 72000 Balance:800. 2 Account holder: Ahmed Abdullah Account ID: 7200 Account number: 72001 Balance:90365. 25
Do you want to do another service [y-yes l n-NO]: y Select a service from the following list 1-Create new account 2- Account Details 3- Deposit 4 Withdraw 5- Display al accounts details Your selection> 3 *e+Money Deposit Please Enter the Account ID 18003 This is not a correct ID Do you want to do another service [y-yes l n-NO]: y Select a service from the following list 1- Create new account 2- Account Details 3- Deposit -Withdraw 5- Display all accounts details Your selection >>3 Money Deposit
Enter the amount of money you would like to deposit 79503 Do you want to do another service [y-yes l n-NO]: y Select a service from the following list 1-Create new account 2- Account Details 3- Deposit 4- Withdraw 5- Display all accounts details Your selection >> 4 Money Withdraw Please Enter the Account ID 18001 Enter the amount of money you would like to withdraw 199999 Insufficient funds. Withdraval not made Do you want to do another service [y-yes l n-NO]: y Select a service from the following list 1-Create new account 2- Account Details 3- Deposit 4- Withdranw 5- Display all accounts details
No SIM令 12:43 AM Group Assignment rlease Enter tre Account IU : Ιδυυι Enter the amount of money you would like to withdraw 50000 6 of 7 successful Do you want to do another service [y-yes I n-NO] : y Select a service from the following list 1- Create new account 2- Account Details 3- Deposit 4- Withdraw 5- Display all accounts details Your selection >5 All Account Details Account holder: Mona Alluwaym Account ID: 72000 Account number Balance:80303. 2 Account holder: Ahmed Abdullah Account ID: 7200 Account number: Balance:40365. 25 Do you want to do another service [y- yes n- NO]: N Exiting program
The final output should look something like this (Note: that the names and balance of accounts can be different depending on the users input. Welcome to JUC Bank Please enter the number of accounts you would like to manage5 Select a service from the following list 1- Create new account 2- Account Details 3- Deposit - Withdraw 5- Display all accounts details Your selection> 2 No account has been created yet Do you want to do another service [y-yes l n-NO]: y Select a service from the following list lCreate new account 2- Account Details 3- Deposit 4- Withdraw 5- Display all accounts details Your selection> 1
Customer name: Mona Alluwaym Balance: 800.2 Do you want to do another service [y- yes n- No]: y Select a service from the following list 1- Create new account 2- Account Details 3- Deposit 4-Withdraw 5- Display all accounts details Your selection >>> 1 Customer name: Balance: 90365. 25 Ahmed Abdullah Do you want to do another service [y- yes n NO]: Y Select a service from the following list 1- Create new account 2- Account Details 3- Deposit 4-Withdraw 5- Display all accounts details Your selection >> 5 All Account Details Account holder: Mona Alluwaym Account ID: 72000 Account number: 72000 Balance:800. 2 Account holder: Ahmed Abdullah Account ID: 7200 Account number: 72001 Balance:90365. 25
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
class Account{
private int ID, AccNo;
private String name;
private double balance;
public Account(int ID, int AccNo,String name, double balance){
this.ID = ID;
this.AccNo = AccNo;
this.name = name;
this.balance = balance;
}
public void setName(String name){
this.name = name;
}
public void setBalance(double balance){
this.balance = balance;
}
public int getID(){
return ID;
}
public int getAccNo(){
return AccNo;
}
public String getName(){
return name;
}
public double getBalance(){
return balance;
}
public boolean deposit(double d){
if(d>0){
balance += d;
return true;
}
return false;
}
public boolean withdraw(double b){
if(b>balance)
return false;
balance -= b;
return true;
}
}
class JUCBank{
static int trackID=180000, trackAccNo=720000;
public static int getIndex(Account account[],int id,int n){
for(int i=0;i<n;i++){
if(account[i].getID()==id)
return i;
}
return -1;
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int numAccounts,i=0;
System.out.println("Welcome to JUC Bank");
System.out.println("----------------------------------------");
System.out.println("Please enter the number of accounts you would like to manage : ");
numAccounts = keyboard.nextInt();
Account account[] = new Account[5];
while(i<numAccounts){
System.out.println("----------------------------------------");
System.out.println("\nSelect a service from the following list");
System.out.println("----------------------------------------");
System.out.println("1- Create new account\n2- Account Details\n3- Deposit\n4- Withdraw\n5- Display all accounts details");
System.out.print("Your selection >>> ");
int selection = keyboard.nextInt();
if(selection==1){
System.out.println("**********Create new account*********");
System.out.print("Customer name: ");
keyboard.nextLine();
String name = keyboard.nextLine();
System.out.print("Balance: ");
double balance = keyboard.nextDouble();
account[i++] = new Account(trackID,trackAccNo,name,balance);
trackAccNo += 1;
trackID += 1;
}
else if(selection==2){
if(i==0)
System.out.print("No account has been created yet");
else{
System.out.println("*******All Account Details*******\n");
for(int j=0;j<i;j++)
System.out.println("Account holder: "+account[j].getName()+" Account ID: "+account[j].getID()+" Account number: "+account[j].getAccNo()+"\nBalance:"+account[j].getBalance());
}
}
else if(selection==3){
System.out.println("*************Money Deposit**************");
System.out.print("Please Enter the Account ID : ");
int id = keyboard.nextInt();
int index = getIndex(account,id,i);
if(index>=0){
System.out.print("Enter the amount of money you would like to deposit : ");
double d = keyboard.nextDouble();
if(!account[index].deposit(d))
System.out.print("deposit amount should be positive");
}else System.out.println("This is not a correct ID");
}
else if(selection==4){
System.out.print("*************Money Withdraw***************\n");
System.out.print("Please Enter the Account ID : ");
int id = keyboard.nextInt();
System.out.print("Enter the amount of money you would like to withdraw : ");
double w = keyboard.nextDouble();
int index = getIndex(account,id,i);
if(index>=0){
if(!account[index].withdraw(w))
System.out.println("Insufficient funds. Withdrawal not made.");
}else System.out.println("This is not a correct ID");
}
else if(selection==5){
System.out.println("*******All Account Details*******\n");
for(int j=0;j<i;j++)
System.out.println("Account holder: "+account[j].getName()+" Account ID: "+account[j].getID()+" Account number: "+account[j].getAccNo()+"\nBalance:"+account[j].getBalance());
}
System.out.println("------------------------------------------------------");
System.out.println("Do you want to do another service [y- yes | n- NO]: ");
char option = keyboard.next().charAt(0);
if(option=='n')
break;
System.out.print("\n");
}
}
}

//output screenshot

C:\java>java JUCBank Welcome to JUC Bank Please enter the number of accounts you would like to manage Select a service from the following list 1- Createnew account 2-Account Details 3- Deposit 4- Withdraw 5- Display all accounts details Your selection >> 1 *** Create new account****x* Customer name: Linus Paul Balance: 3230 Do you want to do another service [y- yes n- NO]: Select a service from the following list 1- Createnew account 2- Account Details 3- Deposit 4- Withdraw 5- Display all accounts details Your selection >>>2 Account holder: Linus Paul Account ID: 180000 Account number: 720000 Balance:3230.0

//any query, post in the comment section

Add a comment
Know the answer?
Add Answer to:
This assignment must be completed on your own with your team mates. Don't give your code...
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
  • answer in c++ code. use comments when writing the code to know what's your thinking. there is three pictures with information Write a C++ console program that defines and utilizes a cl...

    answer in c++ code. use comments when writing the code to know what's your thinking. there is three pictures with information Write a C++ console program that defines and utilizes a class named ATM. This program will demonstrate a composition relationship among classes because an ATM can contain many Accounts. You will need to reuse/modify the Account class you created in Assignment 10. The default constructor for the ATM class should initialize a private vector of 10 accounts, each with...

  • Java Code: 2. Define a class ACCOUNT with the following members: Private members Acno of type...

    Java Code: 2. Define a class ACCOUNT with the following members: Private members Acno of type int Name of type String Balance of type float Public members void Init) method to enter the values of data members void Show) method to display the values of data members void Deposit(int Amt) method to increase Balance by Amt void Withdraw(int Amt) method to reduce Balance by Amt (only if required balance exists in account) float RBalance() member function that returns the value...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • how can i code this only using a textbox for results Create Windows Forms applications called...

    how can i code this only using a textbox for results Create Windows Forms applications called ATM Project that allows the customer to deposit the initial amount and enter the amount to be withdrawn. You need to display the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn including any service charges. The ATM allows a customer to withdraw a maximum of $500 per transition in $20 increments. If a...

  • 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...

  • •create a new savings account object (for choice 2). •ask the user to enter an initial...

    •create a new savings account object (for choice 2). •ask the user to enter an initial balance which should be greater than 50. If the entered amount is less than 50, the program will ask the user to enter another amount. This continues until an amount greater than 50 is entered. •Set the balance of the savings account object by calling the setBalance() method. •Ask the user to deposit an amount. Deposit that amount and display the balance of the...

  • *This question was posted earlier but I want to make sure my code differs from the...

    *This question was posted earlier but I want to make sure my code differs from the other answer* CS50 Assignment 3 and Assignment 4 (Both Due By Sunday March 29 11:59 PM) Assignment 3: Bank Application In a recent lecture, we discussed getting input from the user by using the scanf() function. For your reference, I have included a simple example of using scanf() below: scanf() example: #include int main(void) { int number; printf("Enter a number: "); //prompt the user...

  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank...

    please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much! public abstract class BankAccount {    //declare the required class variables    private double balance;    private int num_deposits;    private int num_withdraws;    private double annualInterest;    private double serviceCharges;       //constructor that takes two arguments    // one is to initialize the balance and other    // to initialize the annual interest rate       public BankAccount(double balance,...

  • BANKING MANAGEMENT

    Banking System is developed in C++ to replaced manual System by a computerized system. This system allows to create a new account and Allows to deposit and withdrawal amount facilities. Account Holder ABS must record the detailed information of each account holder, such as  Type of his account (see next slides for more info)  Type of Credit card (see later slides for more info)  First name, middle name, and last name  CNIC number Address Telephone number Date of...

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
ADVERTISEMENT