Java Case study


Problem Statement:
You owe the credit card company 1000.00 rupee. The company charges you 1.5% per month on the unpaid balance. You have decided to stop using the card and to pay off the debt by making a monthly payment of N rupee a month. Write a program that asks for the monthly payment, the program writes out the balance and total payments so far for every succeeding month until the balance is zero or less.
Sample Input :
Enter the monthly payment: 100
Sample Output:
Month: 1 balance: 915.0 total payments: 100.0
Month: 2 balance: 828.725 total payments: 200.0
Month: 3 balance: 741.155875 total payments: 300.0

 

 

Solution:

 

package javaapplication1;

 

public class CompundInterest {

 

public static void main(String[] args){

double amountdeposit=100000;
int i = 0;
double rateofinterest=0.05;
int finalamount=0;

 

double Interestamountoftheyear;

if(i==0){
System.out.println(“Interest amount for “+i+”year”+amountdeposit);
++i;
if(i==1){
Interestamountoftheyear=amountdeposit*rateofinterest;

 

finalamount=(int) (amountdeposit+Interestamountoftheyear);
System.out.println(“Interest amount for “+i+”year”+finalamount);
++i;

while(finalamount<=1000000 && i>1){

Interestamountoftheyear=finalamount*rateofinterest;
finalamount=(int) (finalamount+Interestamountoftheyear);
System.out.println(“Interest amount for “+i+”year”+finalamount);
++i;
}

}

}

}

}

 

 

 

 

 

 

Advertisements

Leave a Reply to assist you..

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s