-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm.java
More file actions
43 lines (43 loc) · 1.68 KB
/
Copy pathForm.java
File metadata and controls
43 lines (43 loc) · 1.68 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
//class declaration
public class Form {
//non-static members
public String name;
public String location;
public double tenthpercent;
public double interpercent;
public double btechpercent;
public double mtechpercent;
//first constructor
public Form(String name, String location, double tenthpercent) {
this.name = name;
this.location = location;
this.tenthpercent = tenthpercent;
}
//second constructor
public Form(String name, String location, double tenthpercent, double interpercent) {
this(name, location, tenthpercent);
this.interpercent = interpercent;
}
//third constructor
public Form(String name, String location, double tenthpercent, double interpercent, double btechpercent) {
this(name, location, tenthpercent, interpercent);
this.btechpercent = btechpercent;
}
//fourth constructor
public Form(String name, String location, double tenthpercent, double interpercent, double btechpercent, double mtechpercent) {
this(name, location, tenthpercent, interpercent, btechpercent);
this.mtechpercent = mtechpercent;
}
//display method
public void DisplayDetails() {
System.out.println(name, location, tenthpercent);
System.out.println(name, location, tenthpercent, interpercent);
System.out.println(name, location, tenthpercent, interpercent, btechpercent);
System.out.println(name, location, tenthpercent, interpercent, btechpercent, mtechpercent);
}
//main method
public static void main(String[] args) {
Form form = new Form("jess", "hyd", 10.0, 9.0, 8.0, 7.0);
form.DisplayDetails();
}
}