Computer Applications
Write a program to input Principal (p), Rate (r) and Time (t). Calculate and display the amount, which is compounded annually for each year by using the formula:
Simple Interest:
(si) = (prt) / 100
p = p + si
[Hint: The amount after each year is the Principal for the next year]
Java
Java Iterative Stmts
57 Likes
Answer
import java.util.Scanner;
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 Rate: ");
double r = in.nextDouble();
System.out.print("Enter Time: ");
int t = in.nextInt();
double amt = p;
for (int i = 1; i <= t; i++) {
double interest = (amt * r * 1) / 100.0;
amt += interest;
System.out.println("Amount after " + i
+ " year = " + amt);
}
}
}
Variable Description Table
Program Explanation
Output
Answered By
15 Likes
Related Questions
Write a program in Java to find the sum of the given series:
S = x/2 + x/5 + x/8 + x/11 + …… + x/20
In order to reach the top of a pole, a monkey in his first attempt reaches to a height of 5 feet and in the subsequent jumps, he slips down by 2% of the height attained in the previous jump. The process repeats and finally the monkey reaches the top of the pole. Write a program to input height of the pole. Calculate and display the number of attempts the monkey makes to reach the top of the pole.
Write a menu driven program to input two positive numbers m and n (where m>n) and perform the following tasks:
(a) Find the sum of two numbers without using '+' operator.
(b) Find the product of two numbers without using '*' operator.
(c) Find the quotient and remainder of two numbers without using '/' and '%' operator.
[Hint: The last value obtained after each subtraction is the remainder and the number of iterations results in quotient.]
Sample Input: m=5, n=2
5 - 2 =3
3 - 2 = 1, thus Quotient = 2 and Remainder = 1Write a menu driven class to accept a number from the user and check whether it is a Palindrome or a Perfect number.
(a) Palindrome number: (A number is a Palindrome which when read in reverse order is same as in the right order)
Example: 11, 101, 151 etc.
(b) Perfect number: (A number is called Perfect if it is equal to the sum of its factors other than the number itself.)
Example: 6 = 1 + 2 + 3