1. WAP to accept principal, rate and time from the user to calculate simple interest.
Answers
Answer:
Simple Interest formula:-
//Assuming it is Java Programming
import java.util.Scanner;
class SI{
public static void main (String ar []){
Scanner sc=new Scanner (System.in);
System.out.println("Enter Principal, Rate and Time");
double principal=sc.nextDouble();
double rate=sc.nextDouble();
int time=sc.nextInt();
double si=(principal*rate*time)/100;
System.out.println("Simple Interest"+si);
}
}
ProTips:-
- Always provide required data types to variables
- Like rate and principal can be in decimal so it should be in double data type while time is always in integer data type
Formula for Simple Interest::
QBASIC::
CLS
INPUT "Enter the principal",p
INPUT "Enter the rate",r
INPUT "Enter the time",t
PRINT "Your answer : " + (p*r*t)/100
END
JAVA::
import java.util.Scanner;
public class Brainly {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
double p = sc.nextInt();
double r = sc.nextInt();
double t = sc.nextInt();
// first enter principal, then rate and then time in years.
System.out.println("Your answer : " + (p * r * t) / 100.0);
}
}