+ 7
Need a program for loan calculator
For 6 month with 10% interest and input will be the amount
18 odpowiedzi
+ 10
Use 90% for 6 months to find the balance.
4 lines of code added.
https://code.sololearn.com/cp6GXE4Rc84v/?ref=app
If you are paying 10% every month, one way is to find the 10% and then use your total minus the 10% paid to get the balance.
The other way, is to find the 90% so you don't have to minus.
If you have 100 and you paid 10%,
Method 1: 100 - (100 * 10%) = 90
Method 2: 100 * 90% = 90
The "i=0" is used for looping. It will loop from 0 until 5 (< 6), which is 6 times.
Finally prints out amount.
+ 4
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
int months = 3;
for (int i = 0; i < months; i++)
amount = amount * 90 / 100;
System.out.println(amount);
}
}
+ 2
Math.ceil was not taught in any of the lesson path. So, how is this part of the solution to the end of unit project ?
+ 1
samiksha mandhare , this is a code coach task. If you need help show your attempt and if you have problems somebody can help you.
+ 1
Thank you
+ 1
Lam Wei Li many thanks for your solution, but can you please explain it, why you are using 90% and what is the connection between amount "printed" and the int i?
+ 1
Mohamed Sweify, I have edited my original answer to include the explanation.
+ 1
Who can help me with the Loan Calculator answer?
I don't understand Anything! I will thank you
0
import java.util.Scanner;
public class LoanCalC
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println ("enter the principal amou
double amount = sc.nextDouble();
for(int i = 1;i<=6;i++)
{
System.out.println("Month "+i);
System.out.print("Payment 10% of "+amount);
amount = amount-amount*0.1;
System.out.println(" = "+amount);
System.out.println("Remaining amount: "+amount);
}
}
}
0
This is my code
0
Lam Wei Li many thanks for the clarification, have a nice day
0
The Packet Narc, My solution didn't involve Math functions. While it's top-voted, unfortunately, it's not marked as the best answer.
0
Easy fast solution
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//your code goes here
int months = 3;
for (int i = 0; i < months; i++)
amount = amount * 90 / 100;
System.out.println(amount);
}
}
- 1
samiksha mandhare , you need to print just the final amount, remove all other print statements. Also amount should be calculated using Math.ceil method => amount -= Math.ceil (amount *0.1); Finally cast the amount to int => System.out.print ((int) amount) ;
- 1
What's wrong with my code?
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
int result;
for(int i = 1; i<=3; i++) {
result = amount - amount*(10/100);
System.out.println(result);
}
}
}