Java vs Python Comparison


Advertisements

Insert Code in Wordpress


Running your blog on WordPress.com, you just include the following lines before your code.

[sourcecode language="csharp"]
//your code comes here
[/sourcecode]

WordPress.com gives us the facility to avoid worrying about code highlighting. If your code is in between these blocks then it will automatically render as per the language you specified. It can support many languages.

Some of them are..

html

javascript

java

javafx

matlab (keywords only)

objc

perl

php

If you have a self-hosted site, or one hosted on wordpress.org, you should should use the SyntaxHighlighter plugin: wordpress.org/plugins/syntaxhighlighter.

This is the plugin the WordPress team sourced to create this functionality on wordpress.com

For more information see this link

Screen shot:

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;
                                                        }

              }

             }

                                           }

                               }