Write a program to simulate a Banking Application with the following functionality: Setup an Account Holders Profile with Name, Address, phone number and e-mail as user inputs Open an account - Checking and Savings Deposit Money into Checking or Savings account as per users preference Withdraw Money from Checking or Savings account as per users preference Technical Requirements: Use I/O methods, if statements, switch statements, while, do-while and for loops, inputs and outputs and UTIL scanner methods
Write a program to simulate a Banking Application with the following functionality: Setup an Account Holders Profile with Name, Address, phone number and e-mail as user inputs Open an account - Checking and Savings Deposit Money into Checking or Savings account as per users preference Withdraw Money from Checking or Savings account as per users preference Technical Requirements: Use I/O methods, if statements, switch statements, while, do-while and for loops, inputs and outputs and UTIL scanner methods
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
Write a program to simulate a Banking Application with the following functionality: Setup an Account Holders Profile with Name, Address, phone number and e-mail as user inputs Open an account - Checking and Savings Deposit Money into Checking or Savings account as per users preference Withdraw Money from Checking or Savings account as per users preference Technical Requirements: Use I/O methods, if statements, switch statements, while, do-while and for loops, inputs and outputs and UTIL scanner methods
Expert Solution
Step 1
The program is written in java
import java.io.*;
import java.lang.*;
import java.util.Scanner;
import java.util.Random;
class bank{
public String Name;
public String Address;
publiclong phone;
public String email;
publiclong acc_no;
publicfloat checking_money;
publicfloat savings_money;
bank(String na,String adr,long ph, String em)
{
Random random = new Random();
this.Name=na;
this.Address=adr;
this.phone=ph;
this.email=em;
this.acc_no=Math.abs(random.nextLong());
this.checking_money=0;
this.savings_money=0;
System.out.println("Account created successfully");
display();
}
publicvoid display()
{
System.out.println("Name: "+this.Name+"\nAddress: "+this.Address+"\nphone: "+this.phone+"\nemail: "+this.email+"\nAccount number: "+this.acc_no+"\nBalance in checking account: "+this.checking_money+"\nBalance in savings account: "+this.savings_money);
}
publicvoid withdraw(float m,int i)
{
if(i==1)
{
if(this.checking_money>m)
{
this.checking_money=this.checking_money-m;
System.out.println("Successfully withdrawed money");
display();
}
else{
System.out.println("insufficient balance");
}
}
else{
if(this.savings_money>m)
{
this.savings_money=this.savings_money-m;
System.out.println("Successfully withdrawed money");
display();
}
else{
System.out.println("insufficient balance");
}
}
}
publicvoid Deposit(float m,int i)
{
if(i==1)
{
this.checking_money=this.checking_money+m;
}
else{
this.savings_money=this.savings_money+m;
}
System.out.println("Successfully deposited money");
display();
}
}
public class Main
{
public static void main(String[] args) {
int ch,i=0,n;
String name,addr,email;
long phone,accno;
float amount;
bank[] b=new bank[10];
Scanner s=new Scanner(System.in);
do{
System.out.println("1.Open account\n2.Deposit Money\n3.Withdraw money\n4.exit\nEnter your choice");
ch=s.nextInt();
switch(ch)
{
case 1:System.out.println("Enter details\n");
s.nextLine();
System.out.println("Enter your name ");
name=s.nextLine();
System.out.println("Enter your address ");
addr=s.nextLine();
System.out.println("Enter your phone number ");
phone=s.nextLong();
s.nextLine();
System.out.println("Enter your email ");
email=s.nextLine();
b[i]=new bank(name,addr,phone,email);
i++;
break;
case 2:System.out.println("Enter the account number: ");
accno=s.nextLong();
for(int j=0;j<i;j++)
{
if(b[j].acc_no==accno)
{
System.out.println("Enter the amount to Deposit");
amount=s.nextFloat();
System.out.println("Enter the type of account\n1.Checking\n2.Savings ");
n=s.nextInt();
b[j].Deposit(amount,n);
}
}
break;
case3: System.out.println("Enter the account number: ");
accno=s.nextLong();
for(int j=0;j<i;j++)
{
if(b[j].acc_no==accno)
{
System.out.println("Enter the amount to withdraw ");
amount=s.nextFloat();
System.out.println("Enter the type of acount\n1.Checking\n2.Savings ");
n=s.nextInt();
b[j].withdraw(amount,n);
}
}
break;
}
}while(ch!=4);
}
}
Step by step
Solved in 2 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education