Mintak Saving Atau Current
unknown
java
3 years ago
3.9 kB
9
Indexable
public static void main(String[] args)
{
int choice=0;
String name,bank;
Scanner scan =new Scanner(System.in);
System.out.println("Creating Account");
System.out.print("Greetings, Which Account would you like to open?\n[1-Saving Account]\n[2-Current Account]\nEnter Here: ");
choice=scan.nextInt();
System.out.print("Insert your name: ");
scan.nextLine();
name= scan.nextLine();
System.out.print("Insert your Bank name: ");
bank= scan.nextLine();
switch (choice)
{
case 1: SavingAccount saveaccount = new SavingAccount();
saveaccount= new SavingAccount(name,bank);
System.out.println(saveaccount);
break;
case 2: CurrentAccount currentAccount = new CurrentAccount();
currentAccount= new CurrentAccount(name,bank);
System.out.println(currentAccount);
break;
}
}
}
class BankAccount
{
protected String fullName, BankName;
protected int accountNumber;
protected String accType;
protected Double interestRate, balance;
public BankAccount(String fullName, String bankName) {
this.fullName = fullName;
BankName = bankName;
}
public BankAccount() {
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getBankName() {
return BankName;
}
public void setBankName(String bankName) {
BankName = bankName;
}
public int getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public String getAccType() {
return accType;
}
public void setAccType(String accType) {
this.accType = accType;
}
public Double getInterestRate() {
return interestRate;
}
public void setInterestRate(Double interestRate) {
this.interestRate = interestRate;
}
public Double getBalance() {
return balance;
}
public void setBalance(Double balance) {
this.balance = balance;
}
}
class SavingAccount extends BankAccount
{
double Newbalance=50;
double NewinterestRate = 0.0005;
public SavingAccount(){
}
public SavingAccount(String name, String BankName){
this.fullName=name;
this.BankName=BankName;
this.setBalance(Newbalance);
this.setInterestRate(NewinterestRate);
}
public String toString() {
return "\n\nCalling From Saving Account [fullName=" + fullName + ", BankName=" + BankName + ", accountNumber=" + accountNumber
+ ", accType=" + accType + ", interestRate=" + interestRate + ", balance=" + balance + "]";
}
}
class CurrentAccount extends BankAccount
{
double Newbalance=200;
double NewinterestRate = 0.0001;
public CurrentAccount(){
}
public CurrentAccount(String name, String BankName){
this.fullName=name;
this.BankName=BankName;
this.setBalance(Newbalance);
this.setInterestRate(NewinterestRate);
}
public String toString() {
return "\n\nCalling From Saving Account [fullName=" + fullName + ", BankName=" + BankName + ", accountNumber=" + accountNumber
+ ", accType=" + accType + ", interestRate=" + interestRate + ", balance=" + balance + "]";
}
}Editor is loading...