Answer:
public class num7 {
/* Interest = (Principal *Rate*Time)/100
Total amount you will have = principal (5000)+Interest
*/
public static void main(String[] args) {
double prinAmount = 5000;
System.out.println("The total amount is "+(calInterest(prinAmount)));
}
static double calInterest(double principal){
int time =1;
double rate = 2.0;
double interest = (principal*rate*time)/100;
double principalPlusInterest = principal+interest;
return principalPlusInterest;
}
}
Step-by-step explanation:
The Logic for this program is:
Interest = (Principal *Rate*Time)/100
Total amount you will have = principal (5000)+Interest
The method calInterest() accepts a double parameter (principal Amount) and uses the logic above to calculate and return the total amount.
The Main Method calls calInterest() and outputs the value calculated in this case since it is hardcoded 5100