Guest_imported
New member
- Jan 1, 1970
- 0
Hi,
I have tried to set the maximum number of fractions displayed to be 2 but when I run my program...the number displayed is only the integers....may I know what goes wrong?
Janet
Codes:
public static void category_menu(c1 a,c1 b,c1 c,c1 d,c1 e,c1 f,c1 g) throws IOException{
BufferedReader stdin = new BufferedReader
(new InputStreamReader(System.in));
String []table = {"Category", "Favourite", "Qty Prepared", "Qty Sold", "Selling Price($)"};
String option;
c1 p, q, r, s, t, u, v;
p = a;
q = b;
r = c;
s = d;
t = e;
u = f;
v = g;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
nf.setMinimumIntegerDigits(1);
System.out.println("\n Cake [c1]"+p.getname()+"\t\t"+ p.display_prepared() + "\t "+ p.display_sold()+"\t\t "+ nf.format(p.price()) );
}
I have tried to set the maximum number of fractions displayed to be 2 but when I run my program...the number displayed is only the integers....may I know what goes wrong?
Janet
Codes:
public static void category_menu(c1 a,c1 b,c1 c,c1 d,c1 e,c1 f,c1 g) throws IOException{
BufferedReader stdin = new BufferedReader
(new InputStreamReader(System.in));
String []table = {"Category", "Favourite", "Qty Prepared", "Qty Sold", "Selling Price($)"};
String option;
c1 p, q, r, s, t, u, v;
p = a;
q = b;
r = c;
s = d;
t = e;
u = f;
v = g;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
nf.setMinimumIntegerDigits(1);
System.out.println("\n Cake [c1]"+p.getname()+"\t\t"+ p.display_prepared() + "\t "+ p.display_sold()+"\t\t "+ nf.format(p.price()) );
}