Java Programme To Calculate Uncomplicated Involvement - Homework Exercise

How to calculate uncomplicated involvement inward Java or Write a Java programme to calculate Simple involvement is a pop Java programming exercise people purpose inward Java course of didactics inward schoolhouse in addition to college. So if you lot cause got late got an homework exercise well-nigh calculating Simple involvement inward Java in addition to wondering How to write Java programme than this tutorial tin assistance you, provided you lot know What is uncomplicated involvement in addition to What is formula of uncomplicated interest. If you lot are completely novel inward Java programming than I would advise to endeavour HelloWorld Example inward Java in addition to sympathise What is Path in addition to Classpath inward Java. IF you lot cause got been doing Java programming in addition to looking for to a greater extent than or less skillful coding exercise than you lot tin besides come across our before programs e.g. calculating Fibonacci serial using recursion, checking if let on is palindrome in addition to How to reverse String inward Java using recursion.



How to calculate Simple Interest inward Java

Here is total code example of Java programme to calculate Simple Interest inward Java. This is an interactive Java programme which accept Input from User using java.util.Scanner class. By the agency simpleInterest() method is reusable method in addition to I cause got made it static in addition to then that I tin telephone band it from main method inward Java without creating object of this class. Its skillful Java exercise to brand utility method static.


How to calculate uncomplicated involvement inward Java or Write a Java programme to calculate Simple inter Java programme to calculate Simple Interest - homework exercise/**
 *
 * Java programme to calculate Simple Interest inward Java.
 * Input to programme is principle, charge per unit of measurement in addition to fourth dimension in addition to output is uncomplicated interest
 * @author
 */

public class SimpleInterestTest{

 
    public static void main(String args[]) {
     
        //creating scanner to convey principle, charge per unit of measurement in addition to fourth dimension input shape user
        Scanner scanner = new Scanner(System.in);
        System.out.println("Welcome inward Java programme to calculate Simple interest");
     
        System.err.println("Please come inward regulation sum :");
        float sum = scanner.nextFloat();
     
        System.err.println("Enter fourth dimension inward years : ");
        float fourth dimension = scanner.nextFloat();
     
        System.out.println("Enter charge per unit of measurement annually : ");
        float charge per unit of measurement = scanner.nextFloat();
     
        float involvement = simpleInterest(amount, rate, time);
     
        System.out.println("Simple interested calculate past times programme is : " + interest);
    }
 
    public static float simpleInterest(float principle, float rate, float time){
        float involvement = (principle*rate*time)/100;
        return interest;
    }
}

Output:
Welcome inward Java programme to calculate Simple interest
Please come inward regulation sum :
1000
Enter fourth dimension inward years :
1
Enter charge per unit of measurement annually :
7
Simple interested calculate past times programme is : 70.0


So nosotros saw nosotros cause got do a static method to calculate uncomplicated involvement for given amount, charge per unit of measurement in addition to time. By the agency this Java programme is non validating input e.g. fourth dimension must live on greater than zero, charge per unit of measurement should live on to a greater extent than than zero, sum tin non live on zilch or negative, which volition live on necessitate if you lot are writing production code.

Further Learning
Data Structures in addition to Algorithms: Deep Dive Using Java
Write a Java programme to calculate GCD of ii numbers inward Java

0 Response to "Java Programme To Calculate Uncomplicated Involvement - Homework Exercise"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel