1.
Create a class named Account which has two methods likes SetCustomerInfo() to set customer’s information’s and Deposit() to set initial deposit value deposited by an account holder. Create a second class Saving Account which inherits Account class and it contains WithdrawSavingMoney() to withdraw specified money. If balance is less than withdrawing money then he is denied to withdraw. This class also contains ShowSavingBalance() to show balance and if balance is less than minimum balance then he would be displayed a message to remind to refill required money to touch your account to minimum balance. Also create a third class CurrentAccount which also inherits Account class and it has methods likes SetOverDraftValue() which sets customer’s credits, that customer can withdraw after his account is exhausted and ShowCurrentBalance() to show total balance with credits. Design this program without using super constructor. Note:- Create three account holders of Saving Account class and three account holders of CurrentAccount Class.
Create a class named Account which has two methods likes SetCustomerInfo() to set customer’s information’s and Deposit() to set initial deposit value deposited by an account holder. Create a second class Saving Account which inherits Account class and it contains WithdrawSavingMoney() to withdraw specified money. If balance is less than withdrawing money then he is denied to withdraw. This class also contains ShowSavingBalance() to show balance and if balance is less than minimum balance then he would be displayed a message to remind to refill required money to touch your account to minimum balance. Also create a third class CurrentAccount which also inherits Account class and it has methods likes SetOverDraftValue() which sets customer’s credits, that customer can withdraw after his account is exhausted and ShowCurrentBalance() to show total balance with credits. Design this program without using super constructor. Note:- Create three account holders of Saving Account class and three account holders of CurrentAccount Class.
Class Account
{
String name;
int age;
int mobileno;
String Gender;
String id;
int deposit;
int withdraw;
void SetCustomerInfo(String n,int
a,int m,String g,String i){
name=n;
age=a;
mobileno=m;
Gender=g;
id=i;
}
void Deposit(int d){
deposit=d;
}
}
class Saving Account extends
Account
{
int saving;
void WithdrawSavingMoney(int w)
{
withdraw=w;
if(withdraw<deposit){
deposit=deposit-withdraw;
System.out.println("Your left
over money="+deposit);
}
}
void ShowSavingBalance(int s) {
saving=s;
if(saving>deposit)
{
System.out.println("Healthy
Account");
}
else{System.out.println("Risky
Account");}
}
}
class CurrentAccount extends
Account
{ int extra;
void CurrentAccount(int e){
extra=e;
}
void ShowCurrentBalance(){
if(deposit<withdraw)
{
deposit=deposit-extra;
System.out.println("Your Main
BAlance="+deposit);
}
else{deposit=deposit-withdraw;
System.out.println("Your left
over money="+deposit);
}
}
}
class callaccount
{
public static void main(String[] args)
{
Saving Account a2=new Saving Account();
CurrentAccount a3=new CurrentAccount();
a2.SetCustomerInfo("Akshar",18,999999999,"Male","a001"
);
a2.Deposit(50);
a2.WithdrawSavingMoney(50);
a2.ShowSavingBalance(50);
a3.SetCustomerInfo("Akshar",18,999999999,"Male","a001"
);
a3.Deposit(50);
a3.CurrentAccount(50);
a3.ShowCurrentBalance();
}}
OUTPUT
Enter the customer name:
KAJ
Enter the account number:
420
Enter the balance
10000
Enter the value of deposit:
2000
Your new balance is :12000.0
Enter the withdraw amount
100
Your balance is: 11900.0
Enter the customer name:
Harsh
Enter the account number:
840
Enter the balance
200
Enter the credits given to the customer:
10
balance:200.0
Credits:10.0
No comments:
Post a Comment