Hooray!!! Here is the first post of this blog. I'm a newbie java programmer and hence will start with a basic program.
Total paises = 3965.0 Paises
Problem statement
Write a program to convert a given Rupees ( it may include paises also) into paises. Rupee and Paise are Indian currency denominations ( 1 Rupee = 100 paises).Sample invocation
paiseConverter 34.565Output
Amount entered = 34.565 RupeesTotal paises = 3965.0 Paises
Learning
- How to split string?
- Converting String to Double
- Reading command line arguments
- How to check a string is numeric type ?
Know-how: Reading command line arguments - How it works?
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
amount = br.readLine();
- System.in : It allows you to read from the standard input (mainly, the console)
- InputStreamReader : It is a bridge from byte streams to character streams.It reads bytes and decodes them into characters using a specified charset.
- BufferedReaders: It read large chunks of data from a file at once, and keep this data in a buffer. When you ask for the next character or line of data, it is retrieved from the buffer. In addition BufferedReader provides more convenient methods such as readLine(), that allow you to get the next line of characters from a file.
Tips
- To display line numbers in eclipse : Window -> preferences -> General -> Text Editors -> Show Line numbers
- Debugging in eclipse: Place break points by double clicking on left most end on editor, select Debug perspective, run in debug mode (select cockroach symbol), once it reaches break point select Step over (F6) or Step Into (F5) and keep watching the variable values.
- Providing command line arguments through eclispe Run Configurations : Run -> Run Configurations -> Arguments -> Program arguments. To make eclipse to prompt for arguments every time we run, add ${string_prompt} in Program arguments.
- This program accepts input from eclipse console.