Computer Applications
Write a program to input the sum. Calculate and display the compound interest in 3 years, when the rates for the successive years are r1%, r2% and r3% respectively.
Hint: [A = P * (1 + (r1 / 100)) * (1 + (r2 / 100)) * (1 + (r3 / 100)) and CI = A - P ]
Java
Java Math Lib Methods
10 Likes
Answer
import java.util.*;
public class KboatCompoundInterest
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter principal: ");
double p = in.nextDouble();
System.out.print("Enter interest rate for 1st year: ");
float r1 = in.nextFloat();
System.out.print("Enter interest rate for 2nd year: ");
float r2 = in.nextFloat();
System.out.print("Enter interest rate for 3rd year: ");
float r3 = in.nextFloat();
double amt = p * (1 + (r1 / 100))
* (1 + (r2 / 100))
* (1 + (r3 / 100));
double ci = amt - p;
System.out.println("Amount after 3 years: Rs. " + amt);
System.out.println("Compound Interest: Rs. " + ci);
}
}
Variable Description Table
Program Explanation
Output
Answered By
4 Likes
Related Questions
The sum of first n odd natural numbers can be calculated as n2, where n is the number of odd natural.
For example,
Sum = 1 + 3 + 5 + 7; number of odd natural = 4
Therefore, Sum = 42 = 16
Write a program to input number of odd natural terms and display sum of the given series:
(a) 1 + 3 + 5 + ………………. + 29 + 31
(b) 1 + 3 + 5 + 7 + ………………. + 47 + 49The volume of a sphere is calculated by using formula:
v = (4/3)*(22/7)*r3Write a program to calculate the radius of a sphere by taking its volume as an input.
Hint: radius = ∛(volume * (3/4) * (7/22))
The standard form of quadratic equation is represented as:
ax2 + bx + c = 0where d= b2 - 4ac, known as 'Discriminant' of the equation.
Write a program to input the values of a, b and c. Calculate the value of discriminant and display the output to the nearest whole number.
A trigonometrical expression is given as:
(Tan A - Tan B) / (1 + Tan A * Tan B)Write a program to calculate the value of the given expression by taking the values of angles A and B (in degrees) as input.
Hint: radian= (22 / (7 * 180)) * degree