Computer Science, asked by musicstudiochannel77, 5 months ago

Write a programme in java

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​

Answers

Answered by vikivignesh285991
3

Answer:

solution 1;

import java.util.Scanner;

public class Use{

 public static void main(String []viki)  

{    

      Scanner scanner = new Scanner(System.in);

        int amount = scanner.nextInt();

        int months;  

        for (months = 6; months>0; months--) {

            amount = amount * 90/100;  

        }

        System.out.println(amount);

}}

Solution 2;

import java.util.Scanner;

public class Use{

 

public static void main(String []viki)  

{    

 

 Scanner sc=new Scanner(System.in);

  double a=sc.nextInt();

      double pay=0;

 

 for(int i=1;i<=10;i++) {

   pay= (double)( ((0.1) * a));

   a=a-pay;

   System.out.println(pay  );

   System.out.println(a   );

   

 }  

}}

Explanation:

     

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

Similar questions