Hi,
I understand that there are two ways in which we can format the o/p.
1)Using the NumberFormat Class AND
2)Using the Decimal Format class.Using the Decimal format class we can create our own output formats.So i wrote down a very simple program to test this.But I came across a problem.
Here is my code
PS: corejava has the Console class.So please don't bother about it.My doubt lies with the DecimalFormat part of the code.
import corejava.*;
import java.text.*;
public class MySalary1
{
public static void main(String[] args)
{
String name,formatout;
int salary;
DecimalFormat df;
df= new DecimalFormat("Rs, 00,00,000.00");
name = Console.readLine("Enter your name");
salary = Console.readInt("Enter your salary");
formatout = df.format(salary);
System.out.println(name + " your salary is " + formatout);
}
}
Please see the format that I have decided to use. It is (Rs,00,00,000).This doesn't work.It always displays the o/p in (Rs 000,000,000,000.00) fashion.How do I display the output in the manner that I want?
Thanks in advance for the help.
Preethi Shetty