19. The Simple Interest (SI) and Compound Interest (CI) of a sum (P) for a given
time (T) and rate (R) can be calculated as:
(1) CI ={[1+r/100]t-1}
(a) SI = p*r*t\100
Write a program to input sum, rate, time and type of Interest ('S' for Simple
Interest and 'C' for Compound Interest). Calculate and display the sum and the interest earned
Answers
Answer:
SI AND CI ARE FOLLOWS
Explanation:
IN PYTHON....
print(" 'S' for simple interest ")
print(" 'C' for compound interest")
a=input("ENTER THE INTEREST TYPE ")
if a=='S':
p=int(input("enter principal amount "))
r=int(input("enter rate of interest "))
t=int(input(" enter time "))
s=p*r*t/100
print("simple interest of your given values = ",s)
SAME FOR CI ALSO.....
Answer:
import java.util.Scanner;
public class Interest
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Program to find the Simple Interest (SI) and Compound Interest (CI)");
System.out.print("Enter the sum:");
double p = in.nextDouble();
System.out.print("Enter the rate of interest:");
double r = in.nextDouble();
System.out.print("Enter the time in years:");
int t = in.nextInt();
System.out.println("Enter type of Interest");
System.out.print("'S'- Simple Interest 'C'- Compound Interest: ");
char type = in.next().charAt(0);
double SI,CI,amt;
switch(type)
{
case 'S': SI= p*r*t/100;
amt = p + SI;
System.out.println("Sum = " + p);
System.out.println("Interest = " + SI);
System.out.println("Sum + Interest = " + amt);
break;
case 'C': CI= p*(Math.pow((1+(r/100)),t)-1);
amt = p + CI;
System.out.println("Sum = " + p);
System.out.println("Interest = " + CI);
System.out.println("Sum + Interest = " + amt);
break;
default:System.out.println("Wrong Coice");
}
}
}