Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BANKING SYSTEM JAVA PLEASE FIX CODE BELOW import java.util.*; import java.io.*; class InsufficientAmount extends Exception { InsufficientAmount(String str) { super(str); } } abstract class CustomerDetails

BANKING SYSTEM JAVA

PLEASE FIX CODE BELOW

import java.util.*; import java.io.*;

class InsufficientAmount extends Exception { InsufficientAmount(String str) { super(str); } }

abstract class CustomerDetails { int custID; String custName; double balance;

CustomerDetails(int id,String cnm,double strbal) { custID=id; custName=cnm; balance=strbal; }

void showDetails() { System.out.println("Customer ID : "+custID); System.out.println("Customer Name : "+custName); System.out.println("Available Balance : "+balance); }

abstract double withdraw(double amount); abstract double deposit(double amount); abstract double calculateInterest(double rate,double year); }

class BankTransactions extends CustomerDetails { BankTransactions(int id,String cnm,double bal) { super(id,cnm,bal); }

double withdraw(double amount) { try { if(balance

double deposit(double amount) { return balance=balance+amount; }

double showUpdatedDetails() { return balance; }

double calculateInterest(double rate,double year) { return balance*year*rate/100; }

}

class BankManagementSystem { public static void main(String args[]) {

String details="*------BankDetails------*"; Scanner sc=new Scanner(System.in); try { FileWriter f1=new FileWriter("Details.txt");

System.out.print(" Enter Customer ID : "); int custID=sc.nextInt(); System.out.print("Enter Customer Name : "); String custName=sc.next(); System.out.print("Enter starting Balance : "); double balance=sc.nextDouble();

details=details+custID+" "+custName+" "+balance;

System.out.println(" ");

int choice; double amount; BankTransactions bt=new BankTransactions(custID,custName,balance); bt.showDetails();

while(true) { System.out.println(" 1. Deposit 2. Withdraw 3. Display balance 4. Interest "); System.out.print("Enter Your choice : "); choice=sc.nextInt(); switch(choice) { case 1:

System.out.print("Enter deposit amount : "); amount=sc.nextDouble(); System.out.println(bt.deposit(amount)); break;

case 2:

System.out.print("Enter withdrawal amount : "); amount=sc.nextDouble(); System.out.println(bt.withdraw(amount)); break;

case 3: System.out.println("Updated balance : "+bt.showUpdatedDetails()); details=details+bt.showUpdatedDetails()+" "; break;

case 4: System.out.print("Enter rate (%): "); int rate=sc.nextInt(); System.out.print("Enter year : "); int year=sc.nextInt(); System.out.println("Interest for saving account : "+bt.calculateInterest(rate,year)); details=details+bt.calculateInterest(rate,year); break; }

String yesNo; System.out.print(" Do you want to continue (yeso)? "); yesNo=sc.next(); if(yesNo.equalsIgnoreCase("no")) { break; } }

f1.write(details); System.out.println(" All details stored successfully into *Details.txt* file!!"); f1.close(); } catch(Exception e1) { System.out.println(e1); } System.out.println(" "); } }

OUTPUT SHOILD LOOK LIKE THIS:

image text in transcribed

Windows PowerShell PS C:\Users\user\Desktop\Chegg\Java\Bank> javac BankManagement System.java PS C:\Users\user\Desktop\Chegg\Java Bank> java BankManagement System Enter Customer ID : 1 Enter Customer Name : PRAVIN Enter starting Balance : 50000 Customer ID : 1 Customer Name : PRAVIN Available Balance : 50000.0 1. Deposit 2. Withdraw 3. Display balance 4. Interest Enter Your choice : 1 Enter deposit amount : 1000 51000.0 Do you want to continue (yeso)? yes 1. Deposit 2. Withdraw 3. Display balance 4. Interest Enter Your choice : 2 Enter withdrawal amount : 500 50500.0 Do you want to continue (yeso)? yes 1. - Deposit Type here to search 4 2:14 PM 1/2018 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

Students also viewed these Databases questions

Question

Describe ways to clarify or restate a clients statement.

Answered: 1 week ago