write a program in java to find and print the simple interest and amount. given , principal = Rs.5000,rate=4%, time = 4 years ?
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class JavaExample
{
public static void main(String args[])
{
float p, r, t, sinterest;
Scanner scan = new Scanner(System.in);
System.out.print("Enter the Principal : ");
p = scan.nextFloat();
System.out.print("Enter the Rate of interest : ");
r = scan.nextFloat();
System.out.print("Enter the Time period : ");
t = scan.nextFloat();
scan.close();
sinterest = (p * r * t) / 100;
System.out.print("Simple Interest is: " +sinterest);
}
}
Please Mark my Answer as Brainliest
Answered by
1
Write a Java program to calculate Simple Interest/**
*
* Java program to calculate Simple Interest in Java.
* Input to program is principle, rate and time and output is simple interest
* @author
*/
public class SimpleInterestTest{
public static void main(String args[]) {
//creating scanner to accept principle, rate and time input form user
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome in Java program to calculate Simple interest");
System.err.println("Please enter principle amount :");
float amount = scanner.nextFloat();
System.err.println("Enter time in years : ");
float time = scanner.nextFloat();
System.out.println("Enter rate annually : ");
float rate = scanner.nextFloat();
float interest = simpleInterest(amount, rate, time);
System.out.println("Simple interested calculate by program is : " + interest);
}
public static float simpleInterest(float principle, float rate, float time){
float interest = (principle*rate*time)/100;
return interest;
}
}
Output:
Welcome in Java program to calculate Simple interest
Please enter principle amount :
1000
Enter time in years :
1
Enter rate annually :
7
Simple interested calculate by program is : 70.0
Similar questions