please sove this programming and don't spam
Answers
The given problem is solved using language - Java.
import java.util.*;
public class Brainly{
public static void main(String s[]){
double principal,rate,time,si=0,amount;
Scanner sc=new Scanner(System.in);
System.out.print("Enter principal amount: ");
principal=sc.nextDouble();
System.out.print("Enter time period in months: ");
time=sc.nextDouble();
sc.close();
if(time<=0)
System.out.println("Invalid Choice. Program terminated.");
else{
if(time<=6){
si=principal*5.0*time/100;
}
else if(time<=12){
si=(principal*5*6/100)+(principal*5.5*(time-6)/100);
}
else if(time<=24){
si=((principal*5*6)+(principal*5.5*6)+(principal*6.0*(time-12)))/100;
}
else if(time<=36){
si=((principal*5*6)+(principal*5.5*6)+(principal*6.0*12)+(principal*6.5*(time-24)))/100;
}
else{
si=((principal*5*6)+(principal*5.5*6)+(principal*6*12)+(principal*6.5*12)+(principal*7*(time-36)))/100;
}
amount=principal+si;
System.out.println("Amount: "+amount);
}
}
}
- Accept the principal and time from the user.
- Check if the entered data is valid or not.
- If valid, calculate the rate of interest as per the conditions given.
- Using formula SI = PTR/100, calculate the simple interest.
- Calculate Amount using formula A = P + SI.
- Display the amount.
See attachment for output.