Showing posts with label simple interest. Show all posts
Showing posts with label simple interest. Show all posts

Tuesday, October 20, 2015

Simple Interest Calculation using jframe(Java GUI)

Write a Java program to calculate a simple interest. This program must be focused on an object oriented approach.

video tutorial link: video

N.B. : Java source code is case sensitive
Source code:  java_simple_interest . java

package java_simple_interest;
//class
class simple_interest
{
    //instance variable
    float principal_amount;
    float year_of_interest;
    float rate_of_interest;
    //method with arguments and return type
    float si(float pa, float yi, float ri)
    {
        return pa*yi*ri;
    }
}

Source Code: calculate_simple_interest . java

(Source code under action button ( jButton1 ))

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       

 // TODO add your handling code here:
        //create object
        simple_interest si =new simple_interest();
        //instance variable getting value from text box
        si.year_of_interest=Float.parseFloat(yoi.getText());
        si.rate_of_interest=Float.parseFloat(roi.getText());
        si.principal_amount=Float.parseFloat(pa.getText());
        //method si called by object si
        jLabel4.setText ("Your Payable interest  is: " + si.si(si.year_of_interest,si.rate_of_interest ,si.principal_amount ));
       
    }          


Saturday, September 12, 2015

Calcualate Simple Interest using java

/*
*Write a C program to find the Simple Interest. Take input for principle amount, rate of interest and time
*from terminal.
*Simple Interest is the money paid by the borrower to the lender, based on the Principle Amount, Interest
*Rate and the Time Period.
*Simple Interest is calculated by, SI= P * T * R / 100 formula.
*Where, P is the Principle Amount.
*T is the Time Period.
*R is the Interest Rate.
*/
package cb_pr175;
import java.util.Scanner;

public class Cb_pr175 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner inp=new Scanner(System.in);
        int pa,ye;
        float rate,si;
        System.out.println("Enter your principal amount");
        pa=inp.nextInt();
        System.out.println("Enter your number of year");
        ye=inp.nextInt();
        System.out.println("Enter your rate of interest");
        rate=inp.nextFloat();
        si=(rate*pa)*ye;
        System.out.println("Your total interest is " + si);
       
    }

}