Developing a Command line utility in todays world will not help your fathers business in any way!!!.. Go for a swing based utility...
newayz...... Dont use \t for indentation. just create a simple function that will return the indented String by padding it with spaces.. Something like this : String pad(String input, int num) { StringBuilder prefix = new StringBuilder(); for(int i = 0;i<num;i++) { prefix.append(" "); } prefix.append(input); return prefix.toString(); } Now you can use this method to pad your strings before printing.. outFile.println(pad("hello",16)); outFile.println(pad("hello",20)); regards Udit tariq masood wrote: > do u send me of your .java files > that I can easily trace your problem. > > > Regards > > Tariq Masood > > > Date: Wed, 29 Apr 2009 03:28:05 -0700 > > Subject: [java ee programming] hi-please help > > From: maskaravi...@gmail.com > > To: java-ee-j2ee-programming-with-passion@googlegroups.com > > > > > > i wanted to write a invoicing program for my father's buisness.i am a > > class X th student and know only the basics.so this is what i have > > done.can u suggest a way to print the output from a printer > > automatically in the same format with the tabs and spaces not > > disappearing as in one of my programs.please help > > package maskara1; > > import java.io.*; > > import java.util.Calendar; > > public class BinodBrothers > > { > > > > static String nam,add,des,dest,ter; > > > > static final int rate[]= > > {3900,4195,185,285,410,729,1140,1712,3200,300,305,312,315,312,132}; > > static int sum=0,tsum=0,cod,inv; > > static int qty[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; > > static int amt[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; > > static int stock[]=new int[15]; > > static int sale[]=new int[15]; > > static int msale[]=new int[15]; > > static String prod[]={"5.5mm Coil ","Tata Tiscon 6mm ","Tata > > Tiscon 8mm ","Tata Tiscon 10mm ","Tata Tiscon 12mm ","Tata Tiscon > > 16mm ","Tata Tiscon 20mm ","Tata Tiscon 25mm ","Balmukund > > ","Balajee ","Lafarge Duraguard","Lafarge Concreto > > ","Ultratech ","Jaypee Buland ","Prince pipes "}; > > static BufferedReader br=new BufferedReader(new InputStreamReader > > (System.in)); > > public static void menu() > > { > > System.out.println("n-Start Billing\nx-End of Day\nr-Change Rate\ns- > > View Stock\nt-View sales\nm-View monthly Sales\np-Enter Purchase Stock > > \nuView Current Rate"); > > System.out.println("1-5.5mm coil2-Tata Tiscon 6mm\n3-Tata Tiscon 8mm > > \n4-Tata Tiscon 10mm\n5-Tata Tiscon 12mm\n6-Tata Tiscon 16mm\n7-Tata > > Tiscon20mm\n8-Tata Tiscon 25mm\n9-Balmukund\n10-Balajee"); > > System.out.println("11-Lafarge Duraguard\n12-Lafarge Concreto\n13- > > Ultratech\n14-Jaypee Buland\n15-Prince Pipes"); > > System.out.println("0-Stop"); > > } > > public static void main(char ch)throws IOException > > { > > switch(ch) > > { > > case 'c': > > cash(); > > break; > > case 'n': > > trigger(); > > bill(); > > break; > > case 'r': > > rate(); > > break; > > case 's': > > stock(); > > break; > > case 't': > > sales(); > > break; > > case 'm': > > month(); > > break; > > case 'p': > > purchase(); > > case 'u': > > currentRate(); > > break; > > case 'x': > > end(); > > break; > > default: > > System.out.println("Invalid choice"); > > } > > } > > public static void cash() > > { > > System.out.println("Total amount of cash flow in the day: Rs."+tsum); > > } > > public static void stock() > > { > > for(int i=0;i<15;i++) > > System.out.println(prod[i]+"\t"+stock[i]); > > } > > public static void sales() > > { > > for(int i=0;i<15;i++) > > System.out.println(prod[i]+"\t"+sale[i]); > > } > > public static void month() > > { > > for(int i=0;i<15;i++) > > System.out.println(prod[i]+"\t"+msale[i]); > > } > > public static void currentRate() > > { > > for(int i=0;i<15;i++) > > System.out.println(prod[i]+"\t"+rate[i]); > > } > > public static void trigger() > > { > > sum=0; > > for(int i=0;i<15;i++) > > { > > qty[i]=0; > > amt[i]=0; > > } > > } > > public static void calc() > > { > > for(int i=0;i<15;i++) > > amt[i]=qty[i]*rate[i]; > > } > > public static void bill() throws IOException > > { > > menu(); > > System.out.println("Billing"); > > System.out.println("Enter the invoice no:"); > > inv=Integer.parseInt(br.readLine()); > > System.out.println("Despatched through:"); > > des=br.readLine(); > > System.out.println("Terms of Delivery:"); > > ter=br.readLine(); > > System.out.println("Destination:"); > > dest=br.readLine(); > > System.out.println("Enter the name:"); > > nam=br.readLine(); > > System.out.println("Enter the address:"); > > add=br.readLine(); > > for(int i=0;i<15;i++) > > { > > System.out.println("Enter the product code:"); > > int co=Integer.parseInt(br.readLine()); > > if(co==0) > > break; > > System.out.println("Enter the quantity:"); > > qty[co-1]=Integer.parseInt(br.readLine()); > > } > > > > calc(); > > FileWriter fw=new FileWriter("output bill.txt"); > > BufferedWriter bw=new BufferedWriter(fw); > > PrintWriter outFile= new PrintWriter(bw); > > int c=0; > > String sub; > > outFile.println("\t\t\t\t\t\t\t\t\t"+inv); > > outFile.print("\n\t\t\t\t\t\t\t\t\t"); > > Calendar d=Calendar.getInstance(); > > outFile.println(d.get(Calendar.DATE)+"/"+d.get(Calendar.MONTH) > > +"/"+d.get(Calendar.YEAR)); > > outFile.println("\n \n\t\t\t\t\t\t\t\t\t"+des+"\n \n\t\t\t\t\t\t\t\t > > \t"+ter+"\n \n\t\t\t\t\t\t\t\t\t"+dest); > > outFile.println("\n \n "); > > outFile.println(nam+"\n"+add); > > outFile.println("\n \n \n \n \n \n \n "); > > for(int i=0;i<15;i++) > > { > > if(qty[i]!=0) > > { > > if(i==0 || i==7 || i==8 || i==9) > > sub="kg "; > > else if(i==10 || i==11 || i==12 ||i==13) > > sub="bags "; > > else > > sub="pcs "; > > if(qty[i]<10) > > outFile.print(" "); > > else if(qty[i]<100) > > outFile.print(" "); > > outFile.print("\t"+prod[i]+"\t "+qty[i]+" "+sub+"\t"); > > > > outFile.println("Rs."+rate[i]+"\t " +"Rs. "+amt[i]); > > c++; > > } > > } > > > > for(int i=c;i<15;i++) > > outFile.println(" "); > > int sum=0; > > for(int i=0;i<15;i++) > > sum+=amt[i]; > > outFile.print("\n\t\t\t\t\t\t\t\t\tRs."+sum); > > outFile.close(); > > > > FileReader fl=new FileReader("output bill.txt"); > > BufferedReader flr=new BufferedReader(fl); > > String text; > > int i=0; > > while((text=flr.readLine())!=null) > > { > > i++; > > System.out.println(text); > > } > > flr.close(); > > update(); > > } > > public static void rate()throws IOException > > { > > do > > { > > System.out.println("Enter the product code:"); > > cod=Integer.parseInt(br.readLine()); > > if(cod==0) > > break; > > System.out.println("Enter the new rate:"); > > rate[cod-1]=Integer.parseInt(br.readLine()); > > } > > while(cod!=0); > > } > > public static void purchase()throws IOException > > { > > do > > { > > System.out.println("Enter the product code:"); > > cod=Integer.parseInt(br.readLine()); > > if(cod==0) > > break; > > System.out.println("Enter the quantity of purchase:"); > > int ch=Integer.parseInt(br.readLine()); > > stock[cod-1]+=ch; > > } > > while(cod!=0); > > } > > public static void update()throws IOException > > { > > tsum+=sum; > > for(int i=0;i<15;i++) > > { > > stock[i]-=qty[i]; > > sale[i]+=qty[i]; > > msale[i]+=sale[i]; > > } > > } > > public static void end()throws IOException > > { > > tsum=0; > > for(int i=0;i<15;i++) > > sale[i]=0; > > } > > } > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en -~----------~----~----~----~------~----~------~--~---