Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java Assessment
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
reece.french
Java Assessment
Commits
9b4e69e6
Commit
9b4e69e6
authored
May 14, 2022
by
reece.french
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assessment Exercise 3
parent
77c2073e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
0 deletions
+121
-0
bankAccount.java
bankAccount.java
+121
-0
No files found.
bankAccount.java
0 → 100644
View file @
9b4e69e6
public
class
bankAccount
{
int
accountNumber
;
String
name
;
int
balance
;
int
addOverdraft
;
public
bankAccount
(
int
ID
,
String
owner
,
int
overallBalance
,
int
overdraftLimit
)
{
accountNumber
=
ID
;
name
=
owner
;
balance
=
overallBalance
;
addOverdraft
=
overdraftLimit
;
}
public
String
display
()
{
return
"Account number: "
+
accountNumber
+
"\n"
+
"Name: "
+
name
+
"\n"
+
"Balance: "
+
"£"
+
balance
+
"\n"
+
"Overdraft: "
+
"£"
+
addOverdraft
+
"\n"
;
}
public
static
void
main
(
String
[]
args
)
{
bankAccount
details
=
new
bankAccount
(
13267845
,
"Reece"
,
2000
,
500
);
details
.
bankFees
(
5
);
System
.
out
.
print
(
details
.
display
());
details
.
deposit
(
0
);
System
.
out
.
println
(
details
.
display
());
details
.
withdrawal
(
3000
,
500
);
System
.
out
.
println
(
details
.
display
());
}
public
int
deposit
(
int
deposit
)
{
balance
=
deposit
+
balance
;
System
.
out
.
println
(
"\n"
+
"You have deposited "
+
"£"
+
deposit
+
"."
+
"\n"
);
return
balance
;
}
public
int
withdrawal
(
int
withdrawal
,
int
limit
)
{
addOverdraft
=
limit
;
if
(
withdrawal
==
balance
)
{
balance
=
0
;
addOverdraft
=
limit
;
}
else
if
(
withdrawal
>
balance
)
{
addOverdraft
=
limit
+
balance
-
withdrawal
;
balance
=
0
;
System
.
out
.
print
(
"\n"
+
"You have gone into your overdraft."
+
"\n"
);
}
else
{
balance
=
balance
-
withdrawal
;
System
.
out
.
println
(
"\n"
+
"You have made a withdrawal of "
+
"£"
+
withdrawal
+
"."
+
"\n"
);
}
return
balance
;
}
public
int
bankFees
(
int
bankFees
)
{
balance
=
balance
-
((
balance
/
100
)
*
bankFees
);
return
balance
;
}
}
class
savingsAccount
extends
bankAccount
{
public
savingsAccount
(
int
ID
,
String
owner
,
int
overallBalance
,
int
overdraftLimit
)
{
super
(
ID
,
owner
,
overallBalance
,
overdraftLimit
);
}
public
String
display
()
{
return
"Account number: "
+
accountNumber
+
"\n"
+
"Name: "
+
name
+
"\n"
+
"Balance: "
+
"£"
+
balance
;
}
public
static
void
main
(
String
[]
args
)
{
savingsAccount
details
=
new
savingsAccount
(
16253702
,
"Reece"
,
1000
,
0
);
details
.
accrueInterest
(
5
);
System
.
out
.
println
(
details
.
display
());
details
.
withdrawal
(
100
);
System
.
out
.
print
(
details
.
display
());
}
public
int
withdrawal
(
int
withdrawal
)
{
balance
=
(
balance
-
withdrawal
);
if
(
withdrawal
>
balance
)
{
balance
=
0
;
System
.
out
.
println
(
"\n"
+
"no additional funds."
+
"\n"
);
}
else
{
System
.
out
.
println
(
"\n"
+
"You have made a withdrawal of "
+
"£"
+
withdrawal
+
"."
+
"\n"
);
}
return
balance
;
}
public
int
accrueInterest
(
int
accrueInterest
)
{
balance
=
balance
+
((
balance
/
100
)
*
accrueInterest
);
return
balance
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment