-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBufferedReader.java
More file actions
34 lines (28 loc) · 1.35 KB
/
BufferedReader.java
File metadata and controls
34 lines (28 loc) · 1.35 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
package technicals;
import java.io.*; //to use BufferedReader we should import the java.io package
import java.text.*;
public class BfER {
public static void main(String[] args) throws IOException
{
DecimalFormat df = new DecimalFormat("0.00");
BufferedReader ip = new BufferedReader( new InputStreamReader(System.in));
System.out.println("Enter a integer type number ");
int num = Integer.parseInt(ip.readLine()); //to take Integer type input from user
System.out.println("Enter a double type number");
double dnum =Double.parseDouble(ip.readLine());//to take Double type input from user
System.out.println("Enter a float type number");
float fnum = Float.parseFloat(ip.readLine());//to take float type input from user
System.out.println("Enter a string");
String st =ip.readLine();//to take String type input from user
System.out.println("Enter a Character");
char ch = (char)ip.read();//to take character type input from user
//for character we can also use readLine as a String type and input a single character
System.out.println(num);
System.out.println(dnum);
System.out.println(fnum);
System.out.println("double number * 3.17 "+ df.format(dnum*3.17));
System.out.println("float number * 3.17 " + df.format(fnum*3.17));
System.out.println(ch);
System.out.println(st);
}
}