Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS570-Java_Projects
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bjv33
CS570-Java_Projects
Commits
d4d57687
Commit
d4d57687
authored
6 years ago
by
bjv33
Browse files
Options
Downloads
Patches
Plain Diff
Loan Payments
parent
1fe46905
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
LoanPayments.java
+41
-0
41 additions, 0 deletions
LoanPayments.java
with
41 additions
and
0 deletions
LoanPayments.java
0 → 100644
+
41
−
0
View file @
d4d57687
// Program: LoanPayments.java
// Purpose: This program calculates how much of your loan payment goes to the principal and how much goes to interest.
// Author: Brian Vojtko
// Date: 10/09/2018
import
java.util.Scanner
;
public
class
LoanPayments
{
public
static
void
main
(
String
[]
args
)
{
//Introduction Display
System
.
out
.
println
(
"Loan Payments"
);
System
.
out
.
println
(
"-----------------"
);
System
.
out
.
println
(
"This program calculates how much of your loan payment goes to the principal and how much goes to interest."
);
System
.
out
.
println
(
" "
);
Scanner
scan
=
new
Scanner
(
System
.
in
);
//Monthly Payment Input
double
payment
=
0.00
;
System
.
out
.
println
(
"Enter your monthly payment: $"
);
payment
=
scan
.
nextDouble
();
//Outstanding Balance Input
double
balance
=
0.00
;
System
.
out
.
println
(
"Enter your outstanding balance: $"
);
balance
=
scan
.
nextDouble
();
//Calculation
double
interest
=
payment
*
0.0451
;
double
principal
=
payment
-
interest
;
interest
=
(
double
)((
int
)((
interest
+
0.005
)
*
100
))/
100
;
principal
=
(
double
)((
int
)((
principal
+
0.005
)
*
100
))/
100
;
//Display Results
System
.
out
.
println
(
"From your payment of $"
+
payment
+
","
);
System
.
out
.
println
(
"$"
+
interest
+
" goes to interest."
);
System
.
out
.
println
(
"$"
+
principal
+
" goes to the principal."
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment