0

please help and give the coding

You take a loan from a friend and need to calculate how much you will owe him after 6 months. You are going to pay him back 10% of the remaining loan amount each month. Create a program that takes the loan amount as input, calculates and outputs the remaining amount after 6 months. Sample Input: 20000 Sample Output: 10628 Here is the monthly payment schedule: Month 1 Payment: 10% of 20000 = 2000 Remaining amount: 18000 Month 2 Payment: 10% of 18000 = 1800 Remaining amount: 16200 Month 3: Payment: 10% of 16200 = 1620 Remaining amount: 14580 Month 4: Payment: 10% of 14580 = 1458 Remaining amount: 13122 Month 5: Payment: 10% of 13122 = 1313 Remaining amount: 11809 Month 6: Payment: 10% of 11809 = 1181 Remaining amount: 10628

29th Dec 2020, 10:08 AM
elsa
12 Antworten
0
elsa Your for loop is totally wrong . Try this : Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int a; for(int i=0;i<6;++i) { amount=amount*9/10; } System.out.println(amount)
29th Dec 2020, 10:30 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 3
elsa what u want to do first U need to learn "for" loop The syntax of for loop is for(initialization;test-condition; increment/decrement) { // your code whatever u want to do }
29th Dec 2020, 10:22 AM
NavyaSri
NavyaSri - avatar
+ 1
elsa These Challenges and projects are made to test the users understanding and knowledge .So try doing it yourself for your own progress . If you want help with the codes , Show your attempt first .
29th Dec 2020, 10:12 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
x = 10 and so its greater than 6. the for loop wont execute anything
30th Dec 2020, 6:15 PM
Harshit Patil
Harshit Patil - avatar
0
okay I'll show u my code
29th Dec 2020, 10:15 AM
elsa
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 for(int x = 10;x <= 6;amount*(x/100.0f)); { System.out.println(x); } } } what's wrong here
29th Dec 2020, 10:18 AM
elsa
0
in the if-statement i = 5 is invalid because the compiler will think that u r assigning value of i in condition. correct is i == 5
6th Jan 2021, 9:07 AM
Harshit Patil
Harshit Patil - avatar
0
also that for type conversion, the data type should be enclosed in parentheses
6th Jan 2021, 9:08 AM
Harshit Patil
Harshit Patil - avatar
0
9th Jan 2021, 6:21 AM
muharam ahmad
muharam ahmad - avatar
10th Jan 2021, 4:18 AM
sai theja
sai theja - avatar
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 pay = 0; int rem = amount; for(int i=0;i<3;i++) { pay = rem/10; rem = rem- pay; } System.out.println(rem); } }
26th Jul 2021, 2:01 PM
suma narra
suma narra - avatar
- 1
i need help on this too. I am new to code ,so do not judge. Here was 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(); //your code goes here for(i=0;i<6;i++){ int payment=int (amount*100)%90 int amount=int payment*90/100 if(i=5){ System.out.println(amount); } } }
6th Jan 2021, 7:44 AM
Fikky D
Fikky D - avatar