Sunday, July 19, 2015

Simple Interest Solver in Java

A simple program that I wrote in Java that will ask the user to give the amount loaned, time and interest in the amount and then I will compute the interest rate in the given amount which is being borrowed by the client or customer.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

// Problem : Write a program in Java that computes for simple interest for the amount // that is  being borrow from a bank or financial institution. 
// Date:  June 28, 2015
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Email Address: jakerpomperada@yahoo.com and jakerpomperada@gmail.com

import java.util.Scanner;
import java.text.DecimalFormat;

class interest {
    public static float compute_interest_rate(float principal_amount, float rate, float time)
    {
        float solve_interest = (principal_amount*rate*time)/100;
        return(solve_interest);
    }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
  DecimalFormat df = new DecimalFormat("###.##");
   char a;
do
    {

  System.out.println();
  System.out.println("===== SIMPLE AMOUNT INTEREST SOLVER =====");
  System.out.println();
  System.out.print("Enter principle amount being borrowed : PHP ");
  float amount = scan.nextFloat();
      
  System.out.print("Enter number of years to be paid      : ");
  float year = scan.nextFloat();
      
  System.out.print("Enter annual interest rate            : ");
  float rate = scan.nextFloat();
      
  float amount_to_be_paid = compute_interest_rate(amount, rate, year);
      
  System.out.println();

  System.out.print("The total amount of interest to be paid is PHP " + df.format(amount_to_be_paid) +"."); 
 
    System.out.println("\n\n");
    System.out.print("Do you Want To Continue (Y/N) :=> ");
    a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
     System.out.println("\n");
     System.out.println("\t ===== END OF PROGRAM ======");
     System.out.println("\n");
   }
  
  }  // End of Program



No comments:

Post a Comment