Commit 8cba54e4 authored by thomas.fuller's avatar thomas.fuller

finished

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=15
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=15
File added
File added
import java.util.Scanner;
public class Bank {
public static void main(String[] args)
{
Scanner myObj = new Scanner(System.in);
int Choice=0;
int limit=0;
String Name;
double amount;
System.out.println("Welcome to the Bank :");
System.out.println("Press 1 to open Standard Account :");
System.out.println("Press 2 to open Saving Account :");
Choice=myObj.nextInt();
if(Choice==1)
{
StandardBankAccount S1=new StandardBankAccount();
System.out.print("Please Enter You User Name you want :");
Name=myObj.next();
S1.setName(Name);
S1.setAccountNumber(14526398);
System.out.print("Please Enter The Amount you want to deposit to your account :");
amount=myObj.nextDouble();
S1.setBalance(amount);
S1.bankfee();
System.out.print("Please Enter The Overdraft Limit :");
limit=myObj.nextInt();
S1.addOverdraft(limit);
while(Choice!=-1)
{
System.out.println("Press 1 to See account Details :");
System.out.println("Press 2 to Make a Withdraw :");
System.out.println("Press 3 to deposit Amount :");
System.out.println("Press -1 to Exit");
Choice=myObj.nextInt();
if(Choice==1)
{
S1.display();
}
else if(Choice==2)
{
System.out.print("Please Enter the Amount you want to withdraw :");
amount=myObj.nextDouble();
S1.withdraw(amount);
System.out.print("You Amount Have Been withdraw your New Balance is :"+S1.getBalance()+"\n");
if(S1.getBalance()==0)
{
S1.addOverdraft(limit);
}
}
else if(Choice==3)
{
System.out.print("Please Enter The Amount you want to deposit :");
amount=myObj.nextDouble();
S1.deposit(amount);
System.out.print("You Amount Have Been Added your New Balance is :"+S1.getBalance()+"\n");
}
}
}
else if(Choice==2)
{
SavingBankAccount S2=new SavingBankAccount();
System.out.print("Please Enter You User Name you want :");
Name=myObj.next();
S2.setName(Name);
S2.setAccountNumber(45698712);
System.out.print("Please Enter The Amount you want to desport to your account :");
amount=myObj.nextDouble();
S2.setBalance(amount);
S2.accrueInterest();
while(Choice!=-1)
{
System.out.println("Press 1 to See account Details :");
System.out.println("Press 2 to Make a Withdraw :");
System.out.println("Press 3 to deposit Amount :");
System.out.println("Press -1 to Exit");
Choice=myObj.nextInt();
if(Choice==1)
{
S2.display();
}
else if(Choice==2)
{
System.out.print("Please Enter the Amount you want to withdraw :");
amount=myObj.nextDouble();
S2.withdraw(amount);
System.out.print("You Amount Have Been withdraw your New Balance is :"+S2.getBalance()+"\n");
}
else if(Choice==3)
{
System.out.print("Please Enter The Amount you want to deposit :");
amount=myObj.nextDouble();
S2.deposit(amount);
System.out.print("You Amount Have Been Added your New Balance is :"+S2.getBalance()+"\n");
}
else
{
System.out.print("Wrong input!!!"+"\n");
}
}
}
else
{
System.out.print("You Have Enter Wrong Input!!!"+"\n");
}
}
}
public class SavingBankAccount {
private int accountNumber;
private String Name;
private double Balance;
public SavingBankAccount(int accountNumber, String name, double balance) {
super();
this.accountNumber = accountNumber;
Name = name;
Balance = balance;
}
public int getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public double getBalance() {
return Balance;
}
public void setBalance(double balance) {
Balance = balance;
}
public void deposit(double amount)
{
if(amount<0)
{
System.out.print("Can not deposit the amount");
}
else
{
Balance+=amount;
}
}
public SavingBankAccount() {
super();
}
public void withdraw(double amount)
{
if(amount>100)
{
System.out.print("Can not withdraw the amount the limit is 100");
}
else if(Balance<0 && amount<0)
{
System.out.print("Cannot withdraw the amount because Balance is low :");
}
else
{
Balance-=amount;
}
}
public void display()
{
System.out.println("Account Number :"+accountNumber+"\nUser Name :"+Name+"\nAccount Balance :"+"$"+Balance);
}
public void accrueInterest()
{
Balance+=0.05*Balance;
}
}
public class StandardBankAccount {
private int accountNumber;
private String Name;
private double Balance;
public StandardBankAccount(int accountNumber, String name, double balance) {
super();
this.accountNumber = accountNumber;
Name = name;
Balance = balance;
}
public int getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public double getBalance() {
return Balance;
}
public void setBalance(double balance) {
Balance = balance;
}
public void deposit(double amount)
{
if(amount<0)
{
System.out.print("Can not deposit the amount");
}
else
{
Balance+=amount;
}
}
public StandardBankAccount() {
super();
}
public void withdraw(double amount)
{
if(Balance<0 && amount<0)
{
System.out.print("Cannot withdraw the amount because Balance is low :");
}
else
{
Balance-=amount;
}
}
public void bankfee()
{
Balance-=0.05*Balance;
}
public void display()
{
System.out.println("Account Number :"+accountNumber+"\nUser Name :"+Name+"\nAccount Balance :"+"$"+Balance);
}
public void addOverdraft(float limit)
{
if(Balance<= 0)
{
Balance+=limit;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment