0

# Loan Calculator

I'm a Beginner and can't make a Loan calculator can anyone tell what I'm doing wrong in this code - 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 sum1 = 10/100*amount; int sum2 = amount-sum1; int sum3 = 10/100*sum2; int sum4 = sum2-sum3; int sum5 = 10/100*sum4; int sum6 = sum4-sum5; int sum7 = 10/100*sum6; int sum8 = sum6-sum7; int sum9 = 10/100*sum8; int sum10 = sum8-sum9; int sum11 = 10/100*sum10; int sum12 = sum10-sum11; System.out.println(sum11); } }

7th Jan 2021, 5:53 AM
Priyanshu KS
2 ответов
+ 7
This task screams for a loop!!!! First read about loops in the modules. e.g. https://www.sololearn.com/learn/Java/2147/?ref=app Next try to see the pattern. In each operation you're doing the same. i.e. amount = amount - (amount * 0.1); You just take this inside a loop and you're done!
7th Jan 2021, 6:28 AM
Minho
8th Mar 2021, 9:46 PM
AKHY EL MAHEDI