Sunday, March 22, 2015

Calculate Simple Interest using method in java

Write a Java Program to Solve/Calculate of a Simple Interest by given condition. Use Method to solve this issue. Do not use parameter and return value from Method.

Reference:
1. http://c-programming-sourcecode.blogspot.com/2012/07/write-c-program-to-find-simple-interest.html?q=simple+interest
2. Course Book(The Complete Reference Java j2se) ; Page 112

Source Code: 
package calculate;
import java.util.Scanner;
class Interest
{
float SI,t,y,r;
void showValue()
{
System.out.println("The result is :" +((t*y*r)/100));
}
}
public class Calculate
{
public static void main(String[] args)
{
Interest i= new Interest();
Scanner inp=new Scanner(System.in);
System.out.print("Enter the value of t,y,r :");
i.t=inp.nextFloat();
i.y=inp.nextFloat();
i.r=inp.nextFloat();
i.showValue();
}
}

11 comments:

  1. package interest;
    import java.util.Scanner;
    /**@author MainUddin-Feni
    */
    public class Interest {
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    Scanner InputIteam = new Scanner(System.in);
    //Normal Screen Show Message
    System.out.println("Java programming to calculate interest");
    //Input Iteam Entry
    System.err.println("Please enter principle amount: ");
    float MainAmount = InputIteam.nextFloat();
    System.err.println("Enter time in years : ");
    float time = InputIteam.nextFloat();
    System.out.println("Enter The rate Yearly : ");
    float Rate = InputIteam.nextFloat();
    //Mathod Calling and return value Received
    float Resultamountinterest = AUB(MainAmount, Rate, time);
    //OutPut Show
    System.out.println("Simple interested calculate by program is : " + Resultamountinterest);
    }
    public static float AUB(float principleAmount, float Rate, float Time){
    float InterestAmount = (principleAmount*Rate*Time)/100;
    return InterestAmount;
    }
    }

    ReplyDelete
  2. Name-Main Uddin
    ID-201421090
    Batch-46th

    package interest;
    import java.util.Scanner;
    /**@author MainUddin-Feni
    */
    public class Interest {
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    Scanner InputIteam = new Scanner(System.in);
    //Normal Screen Show Message
    System.out.println("Java programming to calculate interest");
    //Input Iteam Entry
    System.err.println("Please enter principle amount: ");
    float MainAmount = InputIteam.nextFloat();
    System.err.println("Enter time in years : ");
    float time = InputIteam.nextFloat();
    System.out.println("Enter The rate Yearly : ");
    float Rate = InputIteam.nextFloat();
    //Mathod Calling and return value Received
    float Resultamountinterest = AUB(MainAmount, Rate, time);
    //OutPut Show
    System.out.println("Simple interested calculate by program is : " + Resultamountinterest);
    }
    public static float AUB(float principleAmount, float Rate, float Time){
    float InterestAmount = (principleAmount*Rate*Time)/100;
    return InterestAmount;
    }
    }

    ReplyDelete
  3. package calculate;
    import java.util.Scanner;
    class Interest
    {
    float SI,t,y,r;
    void showValue()
    {
    System.out.println("The result is :" +((t*y*r)/100));
    }
    }
    public class Calculate
    {
    public static void main(String[] args)
    {
    Interest i= new Interest();
    Scanner inp=new Scanner(System.in);
    System.out.print("Enter the value of t,y,r :");
    i.t=inp.nextFloat();
    i.y=inp.nextFloat();
    i.r=inp.nextFloat();
    i.showValue();
    }

    }

    ReplyDelete
  4. Md : Jalis Mahmud
    Id : 201420762
    Batch_46th

    package calculate;
    import java.util.Scanner;
    public class Interest
    {
    float SI,a,b,c;
    void showValue()
    {
    System.out.println("The result is :" +((a*b*c)/100));
    }
    }
    public class Calculate
    {
    public static void main(String[] args)
    {
    Interest i= new Interest();
    Scanner inp=new Scanner(System.in);
    System.out.print("Enter the value of a,b,c :");
    i.a=inp.nextFloat();
    i.b=inp.nextFloat();
    i.c=inp.nextFloat();
    i.showValue();
    }

    }

    ReplyDelete
  5. ID-201421066
    Batch:46th


    package ex2;
    import java.util.Scanner;

    class benifit{

    int hi ,to,yr,ir;

    void display()
    {
    System.out.println("These result :"+((to*yr*ir)/100));
    }
    }

    public class Ex2 {
    public static void main(String[] args) {
    benifit hh = new benifit();
    Scanner input = new Scanner(System.in);
    System.out.println("Plz enter your required code");
    hh.to = input.nextInt();
    hh.yr = input.nextInt();
    hh.ir = input.nextInt();
    hh.display();
    }

    }

    ReplyDelete
  6. package interest;
    import java.util.Scanner;
    class SimpleInterest
    {
    double principle,rate,period,amount;
    Sinterest()
    {
    amount = ((principle*period)*(rate/100));
    System.out.println("The result is :" +amount);
    }
    }
    public class Calculate
    {
    public static void main(String[] args)
    {
    SimpleInterest si= new SimpleInterest();
    Scanner in=new Scanner(System.in);
    System.out.print("Enter the value of Principle :");
    si.principle=in.nextDouble();
    System.out.print("Enter the value of Period :");
    si.period=in.nextDouble();
    System.out.print("Enter the value of rate :");
    si.rate=in.nextDouble();
    si.Sinterest();
    }

    }

    ReplyDelete
  7. package Calculate;
    import java.util.Scanner;
    class Interest
    {
    double principle,rate,period,amount;
    interest()
    {
    amount = ((principle*period)*(rate/100));
    System.out.println("The result is :" +amount);
    }
    }
    public class Calculate
    {
    public static void main(String[] args)
    {
    Interest si= new Interest();
    Scanner in=new Scanner(System.in);
    System.out.print("The value of Principle :");
    si.principle=in.nextDouble();
    System.out.print("The value of Period :");
    si.period=in.nextDouble();
    System.out.print("The value of rate :");
    si.rate=in.nextDouble();
    si.interest();
    }

    }

    ReplyDelete
  8. Mahmudul Hasan Nayeem
    ID-201420790

    package nayeem02;
    import java.util.Scanner;

    class Mou
    {
    float a, y, r;
    void showValue()
    {
    System.out.println("the result of simple interest is:" + ((a*y*r)/100));
    }
    }
    public class Nayeem02
    {

    public static void main(String[] args)
    {
    Mou m= new Mou();
    Scanner N= new Scanner(System.in);
    System.out.println("enter the value of t, y, r: ");
    m.a=N.nextFloat();
    m.y=N.nextFloat();
    m.r=N.nextFloat();
    m.showValue();
    }

    }

    ReplyDelete
  9. package calculate;
    import java.util.Scanner;
    class Interest
    {
    float SI,t,y,r;
    void showValue()
    {
    System.out.println("The result is :" +((t*y*r)/100));
    }
    }
    public class Calculate
    {
    public static void main(String[] args)
    {
    Interest i= new Interest();
    Scanner inp=new Scanner(System.in);
    System.out.print("Enter the value of t,y,r :");
    i.t=inp.nextFloat();
    i.y=inp.nextFloat();
    i.r=inp.nextFloat();
    i.showValue();
    }

    }

    ReplyDelete
  10. package Calculate;
    import java.util.Scanner;
    class Interest
    {
    double principle,rate,period,amount;
    interest()
    {
    amount = ((principle*period)*(rate/100));
    System.out.println("The result is :" +amount);
    }
    }
    public class Calculate
    {
    public static void main(String[] args)
    {
    Interest si= new Interest();
    Scanner in=new Scanner(System.in);
    System.out.print("The value of Principle :");
    si.principle=in.nextDouble();
    System.out.print("The value of Period :");
    si.period=in.nextDouble();
    System.out.print("The value of rate :");
    si.rate=in.nextDouble();
    si.interest();
    }

    }

    ReplyDelete
  11. ID-201421068
    Batch:46th



    class B_fit{

    int si ,to,yr,ir;

    void display()
    {
    System.out.println("These result :"+((to*yr*ir)/100));
    }
    }

    public class Ex2 {
    public static void main(String[] args) {
    B_fith s = new B_fit();
    Scanner input = new Scanner(System.in);
    System.out.println("Plz enter your required code");
    s.to = input.nextInt();
    s.yr = input.nextInt();
    s.ir = input.nextInt();
    s.display();
    }

    }

    ReplyDelete