Java program to calculate simple interest using constructor overloading for attributes like principal rate and time?

1 answer

Answer

1283375

2026-03-23 03:35

+ Follow

Java
Java

package Javaapplication1;

import Java.util.*;

class amount

{

double amount;

double intrest;

int year;

amount(double a, double i)

{

a=amount;

i=intrest;

int y=year=5;

double s_intrest;

}

}

public class Main

{

public static void main(String[] args)

{

double a,i,s_intrest;

int y=5;

Scanner s=new Scanner(System.in);

a=s.nextDouble();

i=s.nextDouble();

amount a1=new amount(a,i);

s_intrest=(a*i*y)/100;

System.out.println(s_intrest);

}

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.