-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shirshendhu panday #18
Open
Shirshendhu
wants to merge
3
commits into
kishoriak:master
Choose a base branch
from
Shirshendhu:Shirshendhu-Panday
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import java.util.Date; | ||
|
||
public class Account{ | ||
private int perId; | ||
private String perName; | ||
private Date oDate; | ||
private String typeOfAc; | ||
private Double bal; | ||
//private final String code="2308AB0"; | ||
public static int count=0; | ||
|
||
//Default Constructor | ||
public Account(){ | ||
count++; | ||
perId=count; | ||
perName=null; | ||
bal=0.0; | ||
oDate=null; | ||
typeOfAc=null; | ||
} | ||
|
||
//Parameterized Constructor | ||
public Account(String perName,Double bal,String typeOfAc,Date oDate){ | ||
count++; | ||
perId=count; | ||
this.perName=perName; | ||
this.oDate=oDate; | ||
this.typeOfAc=typeOfAc; | ||
this.bal=bal; | ||
} | ||
|
||
//Overriding to display customized entries | ||
@Override | ||
public String toString(){ | ||
|
||
return "Id : "+perId+"\nName : "+perName+"\nBalance : "+bal+"\nDate of opening"+oDate+"\nAccount Type: "+typeOfAc+"\n"; | ||
} | ||
|
||
//Setter getter methods | ||
|
||
/*public void setPerId(int id){ | ||
this.perId=id; | ||
}*/ | ||
public int getPerId(){ | ||
|
||
return this.perId; | ||
} | ||
public void setPerName(String pname){ | ||
|
||
this.perName=pname; | ||
} | ||
public String getPerName(){ | ||
|
||
return this.perName; | ||
} | ||
public void setTypeOfAc(String acType){ | ||
this.typeOfAc=acType; | ||
} | ||
public String getTypeOfAc(){ | ||
return this.typeOfAc; | ||
} | ||
public void setBalance(Double balance){ | ||
|
||
this.bal=balance; | ||
} | ||
public Double getBalance(){ | ||
|
||
return this.bal; | ||
} | ||
|
||
|
||
public void withdraw(Double bl){ | ||
if(bal-10000>=bl) | ||
setBalance(bal-bl); | ||
} | ||
public void deposit(Double bl){ | ||
setBalance(bl+bal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import java.util.Date; | ||
import java.util.Scanner; | ||
//import java.text.SimpleDateFormat; | ||
import java.text.ParseException; | ||
|
||
public class AccountService{ | ||
public static Scanner sc=new Scanner(System.in); | ||
//Create new account | ||
public static void acceptAcData(Account[] parr){ | ||
|
||
for(int i=0;i<parr.length;i++){ | ||
System.out.println("Enter name"); | ||
String nm=sc.next(); | ||
System.out.println("Enter Account Type(Savings/Current)"); | ||
String acType=sc.next(); | ||
System.out.println("Enter Balance"); | ||
Double bal=sc.nextDouble(); | ||
//try{ | ||
parr[i]=new Account(nm,bal,acType,new Date()); | ||
System.out.println("Id is: "); | ||
System.out.println(parr[i].getPerId()); | ||
/*}catch(ParseException e){ | ||
e.printStackTrace(); | ||
}*/ | ||
} | ||
} | ||
//Search by Id | ||
public static int searchById(Account[] parr,int id){ | ||
for(int i=0;i<parr.length;i++){ | ||
if(parr[i].getPerId()==id) | ||
return i; | ||
} | ||
return -1; | ||
} | ||
//Withdraw method | ||
public static void withdrawAmt(Account[] arr,int id,double amt){ | ||
int pos=searchById(arr,id); | ||
if(pos!=-1){ | ||
arr[pos].withdraw(amt); | ||
displayAc(arr, id); | ||
} | ||
else | ||
System.out.println("Person Not found"); | ||
} | ||
//Deposit method | ||
public static void depositAmt(Account[] arr,int id,double amt){ | ||
int pos=searchById(arr,id); | ||
if(pos!=-1){ | ||
arr[pos].deposit(amt); | ||
displayAc(arr, id); | ||
} | ||
else | ||
System.out.println("Person Not found"); | ||
} | ||
|
||
//Display the account | ||
public static void displayAc(Account[] parr, int id){ | ||
int pos=searchById(parr,id); | ||
System.out.println(parr[pos]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import java.util.Date; | ||
import java.util.Scanner; | ||
|
||
import java.text.ParseException; | ||
|
||
public class TestAccountClass{ | ||
public static Scanner sc=new Scanner(System.in); | ||
|
||
public static void main(String args[]){ | ||
Account[] parr=new Account[3]; | ||
AccountService.acceptAcData(parr); | ||
do{ | ||
System.out.println("Press 0 for Create accounts, 1 for Withdraw, 2 for Deposit, 3 for Display or 4 for Exit"); | ||
int c=sc.nextInt(); | ||
switch(c) { | ||
case 0: | ||
AccountService.acceptAcData(parr); | ||
break; | ||
case 1: | ||
System.out.println("Enter id to withdraw:"); | ||
int id = sc.nextInt(); | ||
System.out.println("Enter amount to withdraw:"); | ||
double bal = sc.nextDouble(); | ||
AccountService.withdrawAmt(parr, id,bal); | ||
|
||
break; | ||
case 2: | ||
System.out.println("Enter id to deposit:"); | ||
id = sc.nextInt(); | ||
System.out.println("Enter amount to deposit:"); | ||
bal = sc.nextDouble(); | ||
AccountService.depositAmt(parr, id,bal); | ||
break; | ||
case 3: | ||
System.out.println("Enter id to display:"); | ||
id = sc.nextInt(); | ||
AccountService.displayAc(parr, id); | ||
break; | ||
case 4: | ||
System.exit(0); | ||
break; | ||
default: | ||
System.out.println("Enter correct choice"); | ||
break; | ||
} | ||
}while(1==1); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//All options