-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleInterest.java
More file actions
49 lines (42 loc) · 1.15 KB
/
Copy pathSimpleInterest.java
File metadata and controls
49 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//Manjil Basnet
/* Write a Java program to create a class called “Simple Interest” with a data fields principle, time
and rate, using setter getter method and print the values.*/
public class SimpleInterest {
private double principal;
private double time;
private double rate;
// setter
public void setPrincipal(double principal){
this.principal = principal;
}
public void setTime(double time){
this.time = time;
}
public void setRate(double rate){
this.rate = rate;
}
// getter
public double getPrincipal(){
return principal;
}
public double getTime(){
return time;
}
public double getRate(){
return rate;
}
public void printValues(){
System.out.println("Principle: " + getPrincipal());
System.out.println("Time: " + getTime());
System.out.println("Rate: " + getRate()+"%");
}
}
class SimpleInterestimp{
public static void main(String[] args) {
SimpleInterest SI = new SimpleInterest();
SI.setPrincipal(300000);
SI.setTime(3);
SI.setRate(7.5);
SI.printValues();
}
}