
create a class of object insert with a constructor. write a program to find out simple interest

import java.util.*;
class SimpleInterest
{
double p=0;
double r=0;
double t=0;
SimpleInterest(double p,double r,double t){
this.p=p;
this.r=r;
this.t=t;
}
public void find(){
double rate=r/100;
double si=p*rate*t;
System.out.println("Simple Interest: "+si);
}
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter Principal : ");
double principal=input.nextDouble();
System.out.print("Enter Rate of Interest(%): ");
double rate=input.nextDouble();
System.out.print("Enter Time(years): ");
double time=input.nextDouble();
SimpleInterest interest=new SimpleInterest(principal,rate,time);
interest.find();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.