Skip to content

Commit 56101e1

Browse files
Preciseformat
1 parent 3d12077 commit 56101e1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)