File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ package Demo_Code ;
2
+ import java .lang .reflect .Field ;
3
+ import java .lang .reflect .Method ;
4
+
5
+ class Student {
6
+
7
+ private String name ;
8
+ private int roll_no ;
9
+
10
+ public String getName () {return name ;}
11
+ public void setName (String name ) {this .name =name ;}
12
+ public int getRoll_no () {return roll_no ;}
13
+ public void setRoll_no (int roll_no ) {
14
+ this .roll_no =roll_no ;
15
+ }
16
+
17
+ }
18
+
19
+ public class Practise_1 {
20
+
21
+ public static void main (String [] args ) {
22
+ // TODO Auto-generated method stub
23
+
24
+ Student s1 =new Student ();
25
+
26
+ Class c1 =s1 .getClass ();
27
+
28
+ System .out .println (c1 .getName ());
29
+
30
+ Method m []=c1 .getDeclaredMethods ();
31
+ for (Method method : m )
32
+ System .out .println (method .getName ());
33
+
34
+ Field f []=c1 .getDeclaredFields ();
35
+ for (Field field : f )
36
+ System .out .println (field .getName ());
37
+
38
+ }
39
+
40
+ }
Original file line number Diff line number Diff line change
1
+ package Easy ;
2
+
3
+ import java .util .Scanner ;
4
+
5
+ public class PreciseFormat {
6
+
7
+ public static void printInFormat (float a , float b ) {
8
+
9
+ if (b !=0 ) {
10
+
11
+ float result =a /b ;
12
+ System .out .format ("%.7f " , result );
13
+ System .out .format ("%.3f%n" , result );
14
+ }
15
+ }
16
+
17
+ public static void main (String [] args ) {
18
+ // TODO Auto-generated method stub
19
+ Scanner sc =new Scanner (System .in );
20
+ System .out .print ("Please Enter Float value of a: " );
21
+ float a =sc .nextFloat ();
22
+ System .out .print ("Please Enter Float value of b: " );
23
+ float b =sc .nextFloat ();
24
+
25
+ printInFormat (a ,b );
26
+ }
27
+
28
+ }
You can’t perform that action at this time.
0 commit comments