...
...
.
10. Define a class Interes
Data members int p
class Interest having the following description:
: to enter the principal (sum)
int r
: to enter the rate
int t
: to enter the time
double interest : to store the interest to be paid
double amt
: to store the amount to be paid
Member functions:
input ( : Store the principal, rate, time
calo) : Calculate the interest and amount to be paid
id display ( ) : Displays the principal, interest and amount to be paid
Write a program to compute the interest according to the given conditions and display
the output.
Time
Rate of interest
6.5%
For 1 year
For 2 years
For 3 years
7.5%
8.5%
For 4 years or more
9.5%
(Note: Time to be taken only in whole years)
Answers
Answer:
There are some mistakes in your question....but still I have done whatever I could understand...
HOPE THIS HELPS YOU.
PLEASE MARK ME THE BRAINLIEST.
Answer:
import java.util.Scanner;
public class Interest
{
private int p;
private float r;
private int t;
private double interest;
private double amt;
public void input() {
Scanner in = new Scanner(System.in);
System.out.print("Enter principal: ");
p = in.nextInt();
System.out.print("Enter time: ");
t = in.nextInt();
}
public void cal() {
if (t == 1)
r = 6.5f;
else if (t == 2)
r = 7.5f;
else if (t == 3)
r = 8.5f;
else
r = 9.5f;
interest = (p * r * t) / 100.0;
amt = p + interest;
}
public void display() {
System.out.println("Principal: " + p);
System.out.println("Interest: " + interest);
System.out.println("Amount Payable: " + amt);
}
public static void main(String args[]) {
Interest obj = new Interest();
obj.input();
obj.cal();
obj.display();
}
}