New course! Every coder should learn Generative AI!
Try a free lesson0
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
12 Answers
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)
+ 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
}
+ 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 .
+ 1
x = 10 and so its greater than 6. the for loop wont execute anything
0
okay I'll show u my code
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
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
0
also that for type conversion, the data type should be enclosed in parentheses
0
0
check once
👇👇👇 https://code.sololearn.com/cYpc59r8JbzP/?ref=app
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);
}
}
- 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);
}
}
}